hostapd: Set STA flags when adding a new station
[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 or non-P2P purposes.
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 /*
551  * Driver uses the initial interface for P2P management interface and non-P2P
552  * purposes (e.g., connect to infra AP), but this interface cannot be used for
553  * P2P group operations.
554  */
555 #define WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P           0x00002000
556 /*
557  * Driver is known to use sane error codes, i.e., when it indicates that
558  * something (e.g., association) fails, there was indeed a failure and the
559  * operation does not end up getting completed successfully later.
560  */
561 #define WPA_DRIVER_FLAGS_SANE_ERROR_CODES               0x00004000
562 /* Driver supports off-channel TX */
563 #define WPA_DRIVER_FLAGS_OFFCHANNEL_TX                  0x00008000
564 /* Driver indicates TX status events for EAPOL Data frames */
565 #define WPA_DRIVER_FLAGS_EAPOL_TX_STATUS                0x00010000
566         unsigned int flags;
567
568         int max_scan_ssids;
569
570         /**
571          * max_remain_on_chan - Maximum remain-on-channel duration in msec
572          */
573         unsigned int max_remain_on_chan;
574
575         /**
576          * max_stations - Maximum number of associated stations the driver
577          * supports in AP mode
578          */
579         unsigned int max_stations;
580 };
581
582
583 struct hostapd_data;
584
585 struct hostap_sta_driver_data {
586         unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
587         unsigned long current_tx_rate;
588         unsigned long inactive_msec;
589         unsigned long flags;
590         unsigned long num_ps_buf_frames;
591         unsigned long tx_retry_failed;
592         unsigned long tx_retry_count;
593         int last_rssi;
594         int last_ack_rssi;
595 };
596
597 struct hostapd_sta_add_params {
598         const u8 *addr;
599         u16 aid;
600         u16 capability;
601         const u8 *supp_rates;
602         size_t supp_rates_len;
603         u16 listen_interval;
604         const struct ieee80211_ht_capabilities *ht_capabilities;
605         u32 flags; /* bitmask of WPA_STA_* flags */
606 };
607
608 struct hostapd_freq_params {
609         int mode;
610         int freq;
611         int channel;
612         int ht_enabled;
613         int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
614                                  * secondary channel below primary, 1 = HT40
615                                  * enabled, secondary channel above primary */
616 };
617
618 enum wpa_driver_if_type {
619         /**
620          * WPA_IF_STATION - Station mode interface
621          */
622         WPA_IF_STATION,
623
624         /**
625          * WPA_IF_AP_VLAN - AP mode VLAN interface
626          *
627          * This interface shares its address and Beacon frame with the main
628          * BSS.
629          */
630         WPA_IF_AP_VLAN,
631
632         /**
633          * WPA_IF_AP_BSS - AP mode BSS interface
634          *
635          * This interface has its own address and Beacon frame.
636          */
637         WPA_IF_AP_BSS,
638
639         /**
640          * WPA_IF_P2P_GO - P2P Group Owner
641          */
642         WPA_IF_P2P_GO,
643
644         /**
645          * WPA_IF_P2P_CLIENT - P2P Client
646          */
647         WPA_IF_P2P_CLIENT,
648
649         /**
650          * WPA_IF_P2P_GROUP - P2P Group interface (will become either
651          * WPA_IF_P2P_GO or WPA_IF_P2P_CLIENT, but the role is not yet known)
652          */
653         WPA_IF_P2P_GROUP
654 };
655
656 struct wpa_init_params {
657         const u8 *bssid;
658         const char *ifname;
659         const u8 *ssid;
660         size_t ssid_len;
661         const char *test_socket;
662         int use_pae_group_addr;
663         char **bridge;
664         size_t num_bridge;
665
666         u8 *own_addr; /* buffer for writing own MAC address */
667 };
668
669
670 struct wpa_bss_params {
671         /** Interface name (for multi-SSID/VLAN support) */
672         const char *ifname;
673         /** Whether IEEE 802.1X or WPA/WPA2 is enabled */
674         int enabled;
675
676         int wpa;
677         int ieee802_1x;
678         int wpa_group;
679         int wpa_pairwise;
680         int wpa_key_mgmt;
681         int rsn_preauth;
682         enum mfp_options ieee80211w;
683 };
684
685 #define WPA_STA_AUTHORIZED BIT(0)
686 #define WPA_STA_WMM BIT(1)
687 #define WPA_STA_SHORT_PREAMBLE BIT(2)
688 #define WPA_STA_MFP BIT(3)
689
690 /**
691  * struct p2p_params - P2P parameters for driver-based P2P management
692  */
693 struct p2p_params {
694         const char *dev_name;
695         u8 pri_dev_type[8];
696 #define DRV_MAX_SEC_DEV_TYPES 5
697         u8 sec_dev_type[DRV_MAX_SEC_DEV_TYPES][8];
698         size_t num_sec_dev_types;
699 };
700
701 enum tdls_oper {
702         TDLS_DISCOVERY_REQ,
703         TDLS_SETUP,
704         TDLS_TEARDOWN,
705         TDLS_ENABLE_LINK,
706         TDLS_DISABLE_LINK,
707         TDLS_ENABLE,
708         TDLS_DISABLE
709 };
710
711 /**
712  * struct wpa_signal_info - Information about channel signal quality
713  */
714 struct wpa_signal_info {
715         u32 frequency;
716         int above_threshold;
717         int current_signal;
718         int current_noise;
719         int current_txrate;
720 };
721
722 /**
723  * struct wpa_driver_ops - Driver interface API definition
724  *
725  * This structure defines the API that each driver interface needs to implement
726  * for core wpa_supplicant code. All driver specific functionality is captured
727  * in this wrapper.
728  */
729 struct wpa_driver_ops {
730         /** Name of the driver interface */
731         const char *name;
732         /** One line description of the driver interface */
733         const char *desc;
734
735         /**
736          * get_bssid - Get the current BSSID
737          * @priv: private driver interface data
738          * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
739          *
740          * Returns: 0 on success, -1 on failure
741          *
742          * Query kernel driver for the current BSSID and copy it to bssid.
743          * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
744          * associated.
745          */
746         int (*get_bssid)(void *priv, u8 *bssid);
747
748         /**
749          * get_ssid - Get the current SSID
750          * @priv: private driver interface data
751          * @ssid: buffer for SSID (at least 32 bytes)
752          *
753          * Returns: Length of the SSID on success, -1 on failure
754          *
755          * Query kernel driver for the current SSID and copy it to ssid.
756          * Returning zero is recommended if the STA is not associated.
757          *
758          * Note: SSID is an array of octets, i.e., it is not nul terminated and
759          * can, at least in theory, contain control characters (including nul)
760          * and as such, should be processed as binary data, not a printable
761          * string.
762          */
763         int (*get_ssid)(void *priv, u8 *ssid);
764
765         /**
766          * set_key - Configure encryption key
767          * @ifname: Interface name (for multi-SSID/VLAN support)
768          * @priv: private driver interface data
769          * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
770          *      %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
771          *      %WPA_ALG_NONE clears the key.
772          * @addr: Address of the peer STA (BSSID of the current AP when setting
773          *      pairwise key in station mode), ff:ff:ff:ff:ff:ff for
774          *      broadcast keys, %NULL for default keys that are used both for
775          *      broadcast and unicast; when clearing keys, %NULL is used to
776          *      indicate that both the broadcast-only and default key of the
777          *      specified key index is to be cleared
778          * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
779          *      IGTK
780          * @set_tx: configure this key as the default Tx key (only used when
781          *      driver does not support separate unicast/individual key
782          * @seq: sequence number/packet number, seq_len octets, the next
783          *      packet number to be used for in replay protection; configured
784          *      for Rx keys (in most cases, this is only used with broadcast
785          *      keys and set to zero for unicast keys); %NULL if not set
786          * @seq_len: length of the seq, depends on the algorithm:
787          *      TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
788          * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
789          *      8-byte Rx Mic Key
790          * @key_len: length of the key buffer in octets (WEP: 5 or 13,
791          *      TKIP: 32, CCMP: 16, IGTK: 16)
792          *
793          * Returns: 0 on success, -1 on failure
794          *
795          * Configure the given key for the kernel driver. If the driver
796          * supports separate individual keys (4 default keys + 1 individual),
797          * addr can be used to determine whether the key is default or
798          * individual. If only 4 keys are supported, the default key with key
799          * index 0 is used as the individual key. STA must be configured to use
800          * it as the default Tx key (set_tx is set) and accept Rx for all the
801          * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
802          * broadcast keys, so key index 0 is available for this kind of
803          * configuration.
804          *
805          * Please note that TKIP keys include separate TX and RX MIC keys and
806          * some drivers may expect them in different order than wpa_supplicant
807          * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
808          * will trigger Michael MIC errors. This can be fixed by changing the
809          * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
810          * in driver_*.c set_key() implementation, see driver_ndis.c for an
811          * example on how this can be done.
812          */
813         int (*set_key)(const char *ifname, void *priv, enum wpa_alg alg,
814                        const u8 *addr, int key_idx, int set_tx,
815                        const u8 *seq, size_t seq_len,
816                        const u8 *key, size_t key_len);
817
818         /**
819          * init - Initialize driver interface
820          * @ctx: context to be used when calling wpa_supplicant functions,
821          * e.g., wpa_supplicant_event()
822          * @ifname: interface name, e.g., wlan0
823          *
824          * Returns: Pointer to private data, %NULL on failure
825          *
826          * Initialize driver interface, including event processing for kernel
827          * driver events (e.g., associated, scan results, Michael MIC failure).
828          * This function can allocate a private configuration data area for
829          * @ctx, file descriptor, interface name, etc. information that may be
830          * needed in future driver operations. If this is not used, non-NULL
831          * value will need to be returned because %NULL is used to indicate
832          * failure. The returned value will be used as 'void *priv' data for
833          * all other driver_ops functions.
834          *
835          * The main event loop (eloop.c) of wpa_supplicant can be used to
836          * register callback for read sockets (eloop_register_read_sock()).
837          *
838          * See below for more information about events and
839          * wpa_supplicant_event() function.
840          */
841         void * (*init)(void *ctx, const char *ifname);
842
843         /**
844          * deinit - Deinitialize driver interface
845          * @priv: private driver interface data from init()
846          *
847          * Shut down driver interface and processing of driver events. Free
848          * private data buffer if one was allocated in init() handler.
849          */
850         void (*deinit)(void *priv);
851
852         /**
853          * set_param - Set driver configuration parameters
854          * @priv: private driver interface data from init()
855          * @param: driver specific configuration parameters
856          *
857          * Returns: 0 on success, -1 on failure
858          *
859          * Optional handler for notifying driver interface about configuration
860          * parameters (driver_param).
861          */
862         int (*set_param)(void *priv, const char *param);
863
864         /**
865          * set_countermeasures - Enable/disable TKIP countermeasures
866          * @priv: private driver interface data
867          * @enabled: 1 = countermeasures enabled, 0 = disabled
868          *
869          * Returns: 0 on success, -1 on failure
870          *
871          * Configure TKIP countermeasures. When these are enabled, the driver
872          * should drop all received and queued frames that are using TKIP.
873          */
874         int (*set_countermeasures)(void *priv, int enabled);
875
876         /**
877          * deauthenticate - Request driver to deauthenticate
878          * @priv: private driver interface data
879          * @addr: peer address (BSSID of the AP)
880          * @reason_code: 16-bit reason code to be sent in the deauthentication
881          *      frame
882          *
883          * Returns: 0 on success, -1 on failure
884          */
885         int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
886
887         /**
888          * disassociate - Request driver to disassociate
889          * @priv: private driver interface data
890          * @addr: peer address (BSSID of the AP)
891          * @reason_code: 16-bit reason code to be sent in the disassociation
892          *      frame
893          *
894          * Returns: 0 on success, -1 on failure
895          */
896         int (*disassociate)(void *priv, const u8 *addr, int reason_code);
897
898         /**
899          * associate - Request driver to associate
900          * @priv: private driver interface data
901          * @params: association parameters
902          *
903          * Returns: 0 on success, -1 on failure
904          */
905         int (*associate)(void *priv,
906                          struct wpa_driver_associate_params *params);
907
908         /**
909          * add_pmkid - Add PMKSA cache entry to the driver
910          * @priv: private driver interface data
911          * @bssid: BSSID for the PMKSA cache entry
912          * @pmkid: PMKID for the PMKSA cache entry
913          *
914          * Returns: 0 on success, -1 on failure
915          *
916          * This function is called when a new PMK is received, as a result of
917          * either normal authentication or RSN pre-authentication.
918          *
919          * If the driver generates RSN IE, i.e., it does not use wpa_ie in
920          * associate(), add_pmkid() can be used to add new PMKSA cache entries
921          * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
922          * driver_ops function does not need to be implemented. Likewise, if
923          * the driver does not support WPA, this function is not needed.
924          */
925         int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
926
927         /**
928          * remove_pmkid - Remove PMKSA cache entry to the driver
929          * @priv: private driver interface data
930          * @bssid: BSSID for the PMKSA cache entry
931          * @pmkid: PMKID for the PMKSA cache entry
932          *
933          * Returns: 0 on success, -1 on failure
934          *
935          * This function is called when the supplicant drops a PMKSA cache
936          * entry for any reason.
937          *
938          * If the driver generates RSN IE, i.e., it does not use wpa_ie in
939          * associate(), remove_pmkid() can be used to synchronize PMKSA caches
940          * between the driver and wpa_supplicant. If the driver uses wpa_ie
941          * from wpa_supplicant, this driver_ops function does not need to be
942          * implemented. Likewise, if the driver does not support WPA, this
943          * function is not needed.
944          */
945         int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
946
947         /**
948          * flush_pmkid - Flush PMKSA cache
949          * @priv: private driver interface data
950          *
951          * Returns: 0 on success, -1 on failure
952          *
953          * This function is called when the supplicant drops all PMKSA cache
954          * entries for any reason.
955          *
956          * If the driver generates RSN IE, i.e., it does not use wpa_ie in
957          * associate(), remove_pmkid() can be used to synchronize PMKSA caches
958          * between the driver and wpa_supplicant. If the driver uses wpa_ie
959          * from wpa_supplicant, this driver_ops function does not need to be
960          * implemented. Likewise, if the driver does not support WPA, this
961          * function is not needed.
962          */
963         int (*flush_pmkid)(void *priv);
964
965         /**
966          * get_capa - Get driver capabilities
967          * @priv: private driver interface data
968          *
969          * Returns: 0 on success, -1 on failure
970          *
971          * Get driver/firmware/hardware capabilities.
972          */
973         int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
974
975         /**
976          * poll - Poll driver for association information
977          * @priv: private driver interface data
978          *
979          * This is an option callback that can be used when the driver does not
980          * provide event mechanism for association events. This is called when
981          * receiving WPA EAPOL-Key messages that require association
982          * information. The driver interface is supposed to generate associnfo
983          * event before returning from this callback function. In addition, the
984          * driver interface should generate an association event after having
985          * sent out associnfo.
986          */
987         void (*poll)(void *priv);
988
989         /**
990          * get_ifname - Get interface name
991          * @priv: private driver interface data
992          *
993          * Returns: Pointer to the interface name. This can differ from the
994          * interface name used in init() call. Init() is called first.
995          *
996          * This optional function can be used to allow the driver interface to
997          * replace the interface name with something else, e.g., based on an
998          * interface mapping from a more descriptive name.
999          */
1000         const char * (*get_ifname)(void *priv);
1001
1002         /**
1003          * get_mac_addr - Get own MAC address
1004          * @priv: private driver interface data
1005          *
1006          * Returns: Pointer to own MAC address or %NULL on failure
1007          *
1008          * This optional function can be used to get the own MAC address of the
1009          * device from the driver interface code. This is only needed if the
1010          * l2_packet implementation for the OS does not provide easy access to
1011          * a MAC address. */
1012         const u8 * (*get_mac_addr)(void *priv);
1013
1014         /**
1015          * send_eapol - Optional function for sending EAPOL packets
1016          * @priv: private driver interface data
1017          * @dest: Destination MAC address
1018          * @proto: Ethertype
1019          * @data: EAPOL packet starting with IEEE 802.1X header
1020          * @data_len: Size of the EAPOL packet
1021          *
1022          * Returns: 0 on success, -1 on failure
1023          *
1024          * This optional function can be used to override l2_packet operations
1025          * with driver specific functionality. If this function pointer is set,
1026          * l2_packet module is not used at all and the driver interface code is
1027          * responsible for receiving and sending all EAPOL packets. The
1028          * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
1029          * event. The driver interface is required to implement get_mac_addr()
1030          * handler if send_eapol() is used.
1031          */
1032         int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
1033                           const u8 *data, size_t data_len);
1034
1035         /**
1036          * set_operstate - Sets device operating state to DORMANT or UP
1037          * @priv: private driver interface data
1038          * @state: 0 = dormant, 1 = up
1039          * Returns: 0 on success, -1 on failure
1040          *
1041          * This is an optional function that can be used on operating systems
1042          * that support a concept of controlling network device state from user
1043          * space applications. This function, if set, gets called with
1044          * state = 1 when authentication has been completed and with state = 0
1045          * when connection is lost.
1046          */
1047         int (*set_operstate)(void *priv, int state);
1048
1049         /**
1050          * mlme_setprotection - MLME-SETPROTECTION.request primitive
1051          * @priv: Private driver interface data
1052          * @addr: Address of the station for which to set protection (may be
1053          * %NULL for group keys)
1054          * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
1055          * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
1056          * Returns: 0 on success, -1 on failure
1057          *
1058          * This is an optional function that can be used to set the driver to
1059          * require protection for Tx and/or Rx frames. This uses the layer
1060          * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
1061          * (MLME-SETPROTECTION.request). Many drivers do not use explicit
1062          * set protection operation; instead, they set protection implicitly
1063          * based on configured keys.
1064          */
1065         int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
1066                                   int key_type);
1067
1068         /**
1069          * get_hw_feature_data - Get hardware support data (channels and rates)
1070          * @priv: Private driver interface data
1071          * @num_modes: Variable for returning the number of returned modes
1072          * flags: Variable for returning hardware feature flags
1073          * Returns: Pointer to allocated hardware data on success or %NULL on
1074          * failure. Caller is responsible for freeing this.
1075          *
1076          * This function is only needed for drivers that export MLME
1077          * (management frame processing) to %wpa_supplicant or hostapd.
1078          */
1079         struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
1080                                                          u16 *num_modes,
1081                                                          u16 *flags);
1082
1083         /**
1084          * set_channel - Set channel
1085          * @priv: Private driver interface data
1086          * @phymode: HOSTAPD_MODE_IEEE80211B, ..
1087          * @chan: IEEE 802.11 channel number
1088          * @freq: Frequency of the channel in MHz
1089          * Returns: 0 on success, -1 on failure
1090          *
1091          * This function is only needed for drivers that export MLME
1092          * (management frame processing) to wpa_supplicant.
1093          */
1094         int (*set_channel)(void *priv, enum hostapd_hw_mode phymode, int chan,
1095                            int freq);
1096
1097         /**
1098          * set_ssid - Set SSID
1099          * @priv: Private driver interface data
1100          * @ssid: SSID
1101          * @ssid_len: SSID length
1102          * Returns: 0 on success, -1 on failure
1103          *
1104          * This function is only needed for drivers that export MLME
1105          * (management frame processing) to wpa_supplicant.
1106          */
1107         int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
1108
1109         /**
1110          * set_bssid - Set BSSID
1111          * @priv: Private driver interface data
1112          * @bssid: BSSID
1113          * Returns: 0 on success, -1 on failure
1114          *
1115          * This function is only needed for drivers that export MLME
1116          * (management frame processing) to wpa_supplicant.
1117          */
1118         int (*set_bssid)(void *priv, const u8 *bssid);
1119
1120         /**
1121          * send_mlme - Send management frame from MLME
1122          * @priv: Private driver interface data
1123          * @data: IEEE 802.11 management frame with IEEE 802.11 header
1124          * @data_len: Size of the management frame
1125          * Returns: 0 on success, -1 on failure
1126          *
1127          * This function is only needed for drivers that export MLME
1128          * (management frame processing) to wpa_supplicant.
1129          */
1130         int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
1131
1132         /**
1133          * mlme_add_sta - Add a STA entry into the driver/netstack
1134          * @priv: Private driver interface data
1135          * @addr: MAC address of the STA (e.g., BSSID of the AP)
1136          * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
1137          * format (one octet per rate, 1 = 0.5 Mbps)
1138          * @supp_rates_len: Number of entries in supp_rates
1139          * Returns: 0 on success, -1 on failure
1140          *
1141          * This function is only needed for drivers that export MLME
1142          * (management frame processing) to wpa_supplicant. When the MLME code
1143          * completes association with an AP, this function is called to
1144          * configure the driver/netstack with a STA entry for data frame
1145          * processing (TX rate control, encryption/decryption).
1146          */
1147         int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
1148                             size_t supp_rates_len);
1149
1150         /**
1151          * mlme_remove_sta - Remove a STA entry from the driver/netstack
1152          * @priv: Private driver interface data
1153          * @addr: MAC address of the STA (e.g., BSSID of the AP)
1154          * Returns: 0 on success, -1 on failure
1155          *
1156          * This function is only needed for drivers that export MLME
1157          * (management frame processing) to wpa_supplicant.
1158          */
1159         int (*mlme_remove_sta)(void *priv, const u8 *addr);
1160
1161         /**
1162          * update_ft_ies - Update FT (IEEE 802.11r) IEs
1163          * @priv: Private driver interface data
1164          * @md: Mobility domain (2 octets) (also included inside ies)
1165          * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
1166          * @ies_len: Length of FT IEs in bytes
1167          * Returns: 0 on success, -1 on failure
1168          *
1169          * The supplicant uses this callback to let the driver know that keying
1170          * material for FT is available and that the driver can use the
1171          * provided IEs in the next message in FT authentication sequence.
1172          *
1173          * This function is only needed for driver that support IEEE 802.11r
1174          * (Fast BSS Transition).
1175          */
1176         int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
1177                              size_t ies_len);
1178
1179         /**
1180          * send_ft_action - Send FT Action frame (IEEE 802.11r)
1181          * @priv: Private driver interface data
1182          * @action: Action field value
1183          * @target_ap: Target AP address
1184          * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
1185          * @ies_len: Length of FT IEs in bytes
1186          * Returns: 0 on success, -1 on failure
1187          *
1188          * The supplicant uses this callback to request the driver to transmit
1189          * an FT Action frame (action category 6) for over-the-DS fast BSS
1190          * transition.
1191          */
1192         int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
1193                               const u8 *ies, size_t ies_len);
1194
1195         /**
1196          * get_scan_results2 - Fetch the latest scan results
1197          * @priv: private driver interface data
1198          *
1199          * Returns: Allocated buffer of scan results (caller is responsible for
1200          * freeing the data structure) on success, NULL on failure
1201          */
1202          struct wpa_scan_results * (*get_scan_results2)(void *priv);
1203
1204         /**
1205          * set_country - Set country
1206          * @priv: Private driver interface data
1207          * @alpha2: country to which to switch to
1208          * Returns: 0 on success, -1 on failure
1209          *
1210          * This function is for drivers which support some form
1211          * of setting a regulatory domain.
1212          */
1213         int (*set_country)(void *priv, const char *alpha2);
1214
1215         /**
1216          * global_init - Global driver initialization
1217          * Returns: Pointer to private data (global), %NULL on failure
1218          *
1219          * This optional function is called to initialize the driver wrapper
1220          * for global data, i.e., data that applies to all interfaces. If this
1221          * function is implemented, global_deinit() will also need to be
1222          * implemented to free the private data. The driver will also likely
1223          * use init2() function instead of init() to get the pointer to global
1224          * data available to per-interface initializer.
1225          */
1226         void * (*global_init)(void);
1227
1228         /**
1229          * global_deinit - Global driver deinitialization
1230          * @priv: private driver global data from global_init()
1231          *
1232          * Terminate any global driver related functionality and free the
1233          * global data structure.
1234          */
1235         void (*global_deinit)(void *priv);
1236
1237         /**
1238          * init2 - Initialize driver interface (with global data)
1239          * @ctx: context to be used when calling wpa_supplicant functions,
1240          * e.g., wpa_supplicant_event()
1241          * @ifname: interface name, e.g., wlan0
1242          * @global_priv: private driver global data from global_init()
1243          * Returns: Pointer to private data, %NULL on failure
1244          *
1245          * This function can be used instead of init() if the driver wrapper
1246          * uses global data.
1247          */
1248         void * (*init2)(void *ctx, const char *ifname, void *global_priv);
1249
1250         /**
1251          * get_interfaces - Get information about available interfaces
1252          * @global_priv: private driver global data from global_init()
1253          * Returns: Allocated buffer of interface information (caller is
1254          * responsible for freeing the data structure) on success, NULL on
1255          * failure
1256          */
1257         struct wpa_interface_info * (*get_interfaces)(void *global_priv);
1258
1259         /**
1260          * scan2 - Request the driver to initiate scan
1261          * @priv: private driver interface data
1262          * @params: Scan parameters
1263          *
1264          * Returns: 0 on success, -1 on failure
1265          *
1266          * Once the scan results are ready, the driver should report scan
1267          * results event for wpa_supplicant which will eventually request the
1268          * results with wpa_driver_get_scan_results2().
1269          */
1270         int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
1271
1272         /**
1273          * authenticate - Request driver to authenticate
1274          * @priv: private driver interface data
1275          * @params: authentication parameters
1276          * Returns: 0 on success, -1 on failure
1277          *
1278          * This is an optional function that can be used with drivers that
1279          * support separate authentication and association steps, i.e., when
1280          * wpa_supplicant can act as the SME. If not implemented, associate()
1281          * function is expected to take care of IEEE 802.11 authentication,
1282          * too.
1283          */
1284         int (*authenticate)(void *priv,
1285                             struct wpa_driver_auth_params *params);
1286
1287         /**
1288          * set_beacon - Set Beacon frame template
1289          * @priv: Private driver interface data
1290          * @head: Beacon head from IEEE 802.11 header to IEs before TIM IE
1291          * @head_len: Length of the head buffer in octets
1292          * @tail: Beacon tail following TIM IE
1293          * @tail_len: Length of the tail buffer in octets
1294          * @dtim_period: DTIM period
1295          * @beacon_int: Beacon interval
1296          * Returns: 0 on success, -1 on failure
1297          *
1298          * This function is used to configure Beacon template for the driver in
1299          * AP mode. The driver is responsible for building the full Beacon
1300          * frame by concatenating the head part with TIM IE generated by the
1301          * driver/firmware and finishing with the tail part.
1302          */
1303         int (*set_beacon)(void *priv, const u8 *head, size_t head_len,
1304                           const u8 *tail, size_t tail_len, int dtim_period,
1305                           int beacon_int);
1306
1307         /**
1308          * hapd_init - Initialize driver interface (hostapd only)
1309          * @hapd: Pointer to hostapd context
1310          * @params: Configuration for the driver wrapper
1311          * Returns: Pointer to private data, %NULL on failure
1312          *
1313          * This function is used instead of init() or init2() when the driver
1314          * wrapper is used withh hostapd.
1315          */
1316         void * (*hapd_init)(struct hostapd_data *hapd,
1317                             struct wpa_init_params *params);
1318
1319         /**
1320          * hapd_deinit - Deinitialize driver interface (hostapd only)
1321          * @priv: Private driver interface data from hapd_init()
1322          */
1323         void (*hapd_deinit)(void *priv);
1324
1325         /**
1326          * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
1327          * @priv: Private driver interface data
1328          * @params: BSS parameters
1329          * Returns: 0 on success, -1 on failure
1330          *
1331          * This is an optional function to configure the kernel driver to
1332          * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
1333          * can be left undefined (set to %NULL) if IEEE 802.1X support is
1334          * always enabled and the driver uses set_beacon() to set WPA/RSN IE
1335          * for Beacon frames.
1336          */
1337         int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
1338
1339         /**
1340          * set_privacy - Enable/disable privacy (AP only)
1341          * @priv: Private driver interface data
1342          * @enabled: 1 = privacy enabled, 0 = disabled
1343          * Returns: 0 on success, -1 on failure
1344          *
1345          * This is an optional function to configure privacy field in the
1346          * kernel driver for Beacon frames. This can be left undefined (set to
1347          * %NULL) if the driver uses the Beacon template from set_beacon().
1348          */
1349         int (*set_privacy)(void *priv, int enabled);
1350
1351         /**
1352          * get_seqnum - Fetch the current TSC/packet number (AP only)
1353          * @ifname: The interface name (main or virtual)
1354          * @priv: Private driver interface data
1355          * @addr: MAC address of the station or %NULL for group keys
1356          * @idx: Key index
1357          * @seq: Buffer for returning the latest used TSC/packet number
1358          * Returns: 0 on success, -1 on failure
1359          *
1360          * This function is used to fetch the last used TSC/packet number for
1361          * a TKIP, CCMP, or BIP/IGTK key. It is mainly used with group keys, so
1362          * there is no strict requirement on implementing support for unicast
1363          * keys (i.e., addr != %NULL).
1364          */
1365         int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
1366                           int idx, u8 *seq);
1367
1368         /**
1369          * flush - Flush all association stations (AP only)
1370          * @priv: Private driver interface data
1371          * Returns: 0 on success, -1 on failure
1372          *
1373          * This function requests the driver to disassociate all associated
1374          * stations. This function does not need to be implemented if the
1375          * driver does not process association frames internally.
1376          */
1377         int (*flush)(void *priv);
1378
1379         /**
1380          * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
1381          * @priv: Private driver interface data
1382          * @elem: Information elements
1383          * @elem_len: Length of the elem buffer in octets
1384          * Returns: 0 on success, -1 on failure
1385          *
1386          * This is an optional function to add information elements in the
1387          * kernel driver for Beacon and Probe Response frames. This can be left
1388          * undefined (set to %NULL) if the driver uses the Beacon template from
1389          * set_beacon().
1390          */
1391         int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
1392
1393         /**
1394          * read_sta_data - Fetch station data (AP only)
1395          * @priv: Private driver interface data
1396          * @data: Buffer for returning station information
1397          * @addr: MAC address of the station
1398          * Returns: 0 on success, -1 on failure
1399          */
1400         int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
1401                              const u8 *addr);
1402
1403         /**
1404          * hapd_send_eapol - Send an EAPOL packet (AP only)
1405          * @priv: private driver interface data
1406          * @addr: Destination MAC address
1407          * @data: EAPOL packet starting with IEEE 802.1X header
1408          * @data_len: Length of the EAPOL packet in octets
1409          * @encrypt: Whether the frame should be encrypted
1410          * @own_addr: Source MAC address
1411          * @flags: WPA_STA_* flags for the destination station
1412          *
1413          * Returns: 0 on success, -1 on failure
1414          */
1415         int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
1416                                size_t data_len, int encrypt,
1417                                const u8 *own_addr, u32 flags);
1418
1419         /**
1420          * sta_deauth - Deauthenticate a station (AP only)
1421          * @priv: Private driver interface data
1422          * @own_addr: Source address and BSSID for the Deauthentication frame
1423          * @addr: MAC address of the station to deauthenticate
1424          * @reason: Reason code for the Deauthentiation frame
1425          * Returns: 0 on success, -1 on failure
1426          *
1427          * This function requests a specific station to be deauthenticated and
1428          * a Deauthentication frame to be sent to it.
1429          */
1430         int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
1431                           int reason);
1432
1433         /**
1434          * sta_disassoc - Disassociate a station (AP only)
1435          * @priv: Private driver interface data
1436          * @own_addr: Source address and BSSID for the Disassociation frame
1437          * @addr: MAC address of the station to disassociate
1438          * @reason: Reason code for the Disassociation frame
1439          * Returns: 0 on success, -1 on failure
1440          *
1441          * This function requests a specific station to be disassociated and
1442          * a Disassociation frame to be sent to it.
1443          */
1444         int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
1445                             int reason);
1446
1447         /**
1448          * sta_remove - Remove a station entry (AP only)
1449          * @priv: Private driver interface data
1450          * @addr: MAC address of the station to be removed
1451          * Returns: 0 on success, -1 on failure
1452          */
1453         int (*sta_remove)(void *priv, const u8 *addr);
1454
1455         /**
1456          * hapd_get_ssid - Get the current SSID (AP only)
1457          * @priv: Private driver interface data
1458          * @buf: Buffer for returning the SSID
1459          * @len: Maximum length of the buffer
1460          * Returns: Length of the SSID on success, -1 on failure
1461          *
1462          * This function need not be implemented if the driver uses Beacon
1463          * template from set_beacon() and does not reply to Probe Request
1464          * frames.
1465          */
1466         int (*hapd_get_ssid)(void *priv, u8 *buf, int len);
1467
1468         /**
1469          * hapd_set_ssid - Set SSID (AP only)
1470          * @priv: Private driver interface data
1471          * @buf: SSID
1472          * @len: Length of the SSID in octets
1473          * Returns: 0 on success, -1 on failure
1474          */
1475         int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
1476
1477         /**
1478          * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
1479          * @priv: Private driver interface data
1480          * @enabled: 1 = countermeasures enabled, 0 = disabled
1481          * Returns: 0 on success, -1 on failure
1482          *
1483          * This need not be implemented if the driver does not take care of
1484          * association processing.
1485          */
1486         int (*hapd_set_countermeasures)(void *priv, int enabled);
1487
1488         /**
1489          * sta_add - Add a station entry
1490          * @priv: Private driver interface data
1491          * @params: Station parameters
1492          * Returns: 0 on success, -1 on failure
1493          *
1494          * This function is used to add a station entry to the driver once the
1495          * station has completed association. This is only used if the driver
1496          * does not take care of association processing.
1497          */
1498         int (*sta_add)(void *priv, struct hostapd_sta_add_params *params);
1499
1500         /**
1501          * get_inact_sec - Get station inactivity duration (AP only)
1502          * @priv: Private driver interface data
1503          * @addr: Station address
1504          * Returns: Number of seconds station has been inactive, -1 on failure
1505          */
1506         int (*get_inact_sec)(void *priv, const u8 *addr);
1507
1508         /**
1509          * sta_clear_stats - Clear station statistics (AP only)
1510          * @priv: Private driver interface data
1511          * @addr: Station address
1512          * Returns: 0 on success, -1 on failure
1513          */
1514         int (*sta_clear_stats)(void *priv, const u8 *addr);
1515
1516         /**
1517          * set_freq - Set channel/frequency (AP only)
1518          * @priv: Private driver interface data
1519          * @freq: Channel parameters
1520          * Returns: 0 on success, -1 on failure
1521          */
1522         int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
1523
1524         /**
1525          * set_rts - Set RTS threshold
1526          * @priv: Private driver interface data
1527          * @rts: RTS threshold in octets
1528          * Returns: 0 on success, -1 on failure
1529          */
1530         int (*set_rts)(void *priv, int rts);
1531
1532         /**
1533          * set_frag - Set fragmentation threshold
1534          * @priv: Private driver interface data
1535          * @frag: Fragmentation threshold in octets
1536          * Returns: 0 on success, -1 on failure
1537          */
1538         int (*set_frag)(void *priv, int frag);
1539
1540         /**
1541          * sta_set_flags - Set station flags (AP only)
1542          * @priv: Private driver interface data
1543          * @addr: Station address
1544          * @total_flags: Bitmap of all WPA_STA_* flags currently set
1545          * @flags_or: Bitmap of WPA_STA_* flags to add
1546          * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
1547          * Returns: 0 on success, -1 on failure
1548          */
1549         int (*sta_set_flags)(void *priv, const u8 *addr,
1550                              int total_flags, int flags_or, int flags_and);
1551
1552         /**
1553          * set_rate_sets - Set supported and basic rate sets (AP only)
1554          * @priv: Private driver interface data
1555          * @supp_rates: -1 terminated array of supported rates in 100 kbps
1556          * @basic_rates: -1 terminated array of basic rates in 100 kbps
1557          * @mode: hardware mode (HOSTAPD_MODE_*)
1558          * Returns: 0 on success, -1 on failure
1559          */
1560         int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
1561                              int mode);
1562
1563         /**
1564          * set_cts_protect - Set CTS protection mode (AP only)
1565          * @priv: Private driver interface data
1566          * @value: Whether CTS protection is enabled
1567          * Returns: 0 on success, -1 on failure
1568          */
1569         int (*set_cts_protect)(void *priv, int value);
1570
1571         /**
1572          * set_preamble - Set preamble mode (AP only)
1573          * @priv: Private driver interface data
1574          * @value: Whether short preamble is enabled
1575          * Returns: 0 on success, -1 on failure
1576          */
1577         int (*set_preamble)(void *priv, int value);
1578
1579         /**
1580          * set_short_slot_time - Set short slot time (AP only)
1581          * @priv: Private driver interface data
1582          * @value: Whether short slot time is enabled
1583          * Returns: 0 on success, -1 on failure
1584          */
1585         int (*set_short_slot_time)(void *priv, int value);
1586
1587         /**
1588          * set_tx_queue_params - Set TX queue parameters
1589          * @priv: Private driver interface data
1590          * @queue: Queue number (0 = VO, 1 = VI, 2 = BE, 3 = BK)
1591          * @aifs: AIFS
1592          * @cw_min: cwMin
1593          * @cw_max: cwMax
1594          * @burst_time: Maximum length for bursting in 0.1 msec units
1595          */
1596         int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
1597                                    int cw_max, int burst_time);
1598
1599         /**
1600          * valid_bss_mask - Validate BSSID mask
1601          * @priv: Private driver interface data
1602          * @addr: Address
1603          * @mask: Mask
1604          * Returns: 0 if mask is valid, -1 if mask is not valid, 1 if mask can
1605          * be used, but the main interface address must be the first address in
1606          * the block if mask is applied
1607          */
1608         int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
1609
1610         /**
1611          * if_add - Add a virtual interface
1612          * @priv: Private driver interface data
1613          * @type: Interface type
1614          * @ifname: Interface name for the new virtual interface
1615          * @addr: Local address to use for the interface or %NULL to use the
1616          *      parent interface address
1617          * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
1618          * @drv_priv: Pointer for overwriting the driver context or %NULL if
1619          *      not allowed (applies only to %WPA_IF_AP_BSS type)
1620          * @force_ifname: Buffer for returning an interface name that the
1621          *      driver ended up using if it differs from the requested ifname
1622          * @if_addr: Buffer for returning the allocated interface address
1623          *      (this may differ from the requested addr if the driver cannot
1624          *      change interface address)
1625          * @bridge: Bridge interface to use or %NULL if no bridge configured
1626          * Returns: 0 on success, -1 on failure
1627          */
1628         int (*if_add)(void *priv, enum wpa_driver_if_type type,
1629                       const char *ifname, const u8 *addr, void *bss_ctx,
1630                       void **drv_priv, char *force_ifname, u8 *if_addr,
1631                       const char *bridge);
1632
1633         /**
1634          * if_remove - Remove a virtual interface
1635          * @priv: Private driver interface data
1636          * @type: Interface type
1637          * @ifname: Interface name of the virtual interface to be removed
1638          * Returns: 0 on success, -1 on failure
1639          */
1640         int (*if_remove)(void *priv, enum wpa_driver_if_type type,
1641                          const char *ifname);
1642
1643         /**
1644          * set_sta_vlan - Bind a station into a specific interface (AP only)
1645          * @priv: Private driver interface data
1646          * @ifname: Interface (main or virtual BSS or VLAN)
1647          * @addr: MAC address of the associated station
1648          * @vlan_id: VLAN ID
1649          * Returns: 0 on success, -1 on failure
1650          *
1651          * This function is used to bind a station to a specific virtual
1652          * interface. It is only used if when virtual interfaces are supported,
1653          * e.g., to assign stations to different VLAN interfaces based on
1654          * information from a RADIUS server. This allows separate broadcast
1655          * domains to be used with a single BSS.
1656          */
1657         int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
1658                             int vlan_id);
1659
1660         /**
1661          * commit - Optional commit changes handler (AP only)
1662          * @priv: driver private data
1663          * Returns: 0 on success, -1 on failure
1664          *
1665          * This optional handler function can be registered if the driver
1666          * interface implementation needs to commit changes (e.g., by setting
1667          * network interface up) at the end of initial configuration. If set,
1668          * this handler will be called after initial setup has been completed.
1669          */
1670         int (*commit)(void *priv);
1671
1672         /**
1673          * send_ether - Send an ethernet packet (AP only)
1674          * @priv: private driver interface data
1675          * @dst: Destination MAC address
1676          * @src: Source MAC address
1677          * @proto: Ethertype
1678          * @data: EAPOL packet starting with IEEE 802.1X header
1679          * @data_len: Length of the EAPOL packet in octets
1680          * Returns: 0 on success, -1 on failure
1681          */
1682         int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
1683                           const u8 *data, size_t data_len);
1684
1685         /**
1686          * set_radius_acl_auth - Notification of RADIUS ACL change
1687          * @priv: Private driver interface data
1688          * @mac: MAC address of the station
1689          * @accepted: Whether the station was accepted
1690          * @session_timeout: Session timeout for the station
1691          * Returns: 0 on success, -1 on failure
1692          */
1693         int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted, 
1694                                    u32 session_timeout);
1695
1696         /**
1697          * set_radius_acl_expire - Notification of RADIUS ACL expiration
1698          * @priv: Private driver interface data
1699          * @mac: MAC address of the station
1700          * Returns: 0 on success, -1 on failure
1701          */
1702         int (*set_radius_acl_expire)(void *priv, const u8 *mac);
1703
1704         /**
1705          * set_ht_params - Set HT parameters (AP only)
1706          * @priv: Private driver interface data
1707          * @ht_capab: HT Capabilities IE
1708          * @ht_capab_len: Length of ht_capab in octets
1709          * @ht_oper: HT Operation IE
1710          * @ht_oper_len: Length of ht_oper in octets
1711          * Returns: 0 on success, -1 on failure
1712          */
1713         int (*set_ht_params)(void *priv,
1714                              const u8 *ht_capab, size_t ht_capab_len,
1715                              const u8 *ht_oper, size_t ht_oper_len);
1716
1717         /**
1718          * set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
1719          * @priv: Private driver interface data
1720          * @beacon: WPS IE(s) for Beacon frames or %NULL to remove extra IE(s)
1721          * @proberesp: WPS IE(s) for Probe Response frames or %NULL to remove
1722          *      extra IE(s)
1723          * @assocresp: WPS IE(s) for (Re)Association Response frames or %NULL
1724          *      to remove extra IE(s)
1725          * Returns: 0 on success, -1 on failure
1726          *
1727          * This is an optional function to add WPS IE in the kernel driver for
1728          * Beacon and Probe Response frames. This can be left undefined (set
1729          * to %NULL) if the driver uses the Beacon template from set_beacon()
1730          * and does not process Probe Request frames. If the driver takes care
1731          * of (Re)Association frame processing, the assocresp buffer includes
1732          * WPS IE(s) that need to be added to (Re)Association Response frames
1733          * whenever a (Re)Association Request frame indicated use of WPS.
1734          *
1735          * This will also be used to add P2P IE(s) into Beacon/Probe Response
1736          * frames when operating as a GO. The driver is responsible for adding
1737          * timing related attributes (e.g., NoA) in addition to the IEs
1738          * included here by appending them after these buffers. This call is
1739          * also used to provide Probe Response IEs for P2P Listen state
1740          * operations for drivers that generate the Probe Response frames
1741          * internally.
1742          */
1743         int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
1744                              const struct wpabuf *proberesp,
1745                              const struct wpabuf *assocresp);
1746
1747         /**
1748          * set_supp_port - Set IEEE 802.1X Supplicant Port status
1749          * @priv: Private driver interface data
1750          * @authorized: Whether the port is authorized
1751          * Returns: 0 on success, -1 on failure
1752          */
1753         int (*set_supp_port)(void *priv, int authorized);
1754
1755         /**
1756          * set_wds_sta - Bind a station into a 4-address WDS (AP only)
1757          * @priv: Private driver interface data
1758          * @addr: MAC address of the associated station
1759          * @aid: Association ID
1760          * @val: 1 = bind to 4-address WDS; 0 = unbind
1761          * @bridge_ifname: Bridge interface to use for the WDS station or %NULL
1762          *      to indicate that bridge is not to be used
1763          * Returns: 0 on success, -1 on failure
1764          */
1765         int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
1766                            const char *bridge_ifname);
1767
1768         /**
1769          * send_action - Transmit an Action frame
1770          * @priv: Private driver interface data
1771          * @freq: Frequency (in MHz) of the channel
1772          * @wait: Time to wait off-channel for a response (in ms), or zero
1773          * @dst: Destination MAC address (Address 1)
1774          * @src: Source MAC address (Address 2)
1775          * @bssid: BSSID (Address 3)
1776          * @data: Frame body
1777          * @data_len: data length in octets
1778          * Returns: 0 on success, -1 on failure
1779          *
1780          * This command can be used to request the driver to transmit an action
1781          * frame to the specified destination.
1782          *
1783          * If the %WPA_DRIVER_FLAGS_OFFCHANNEL_TX flag is set, the frame will
1784          * be transmitted on the given channel and the device will wait for a
1785          * response on that channel for the given wait time.
1786          *
1787          * If the flag is not set, the wait time will be ignored. In this case,
1788          * if a remain-on-channel duration is in progress, the frame must be
1789          * transmitted on that channel; alternatively the frame may be sent on
1790          * the current operational channel (if in associated state in station
1791          * mode or while operating as an AP.)
1792          */
1793         int (*send_action)(void *priv, unsigned int freq, unsigned int wait,
1794                            const u8 *dst, const u8 *src, const u8 *bssid,
1795                            const u8 *data, size_t data_len);
1796
1797         /**
1798          * send_action_cancel_wait - Cancel action frame TX wait
1799          * @priv: Private driver interface data
1800          *
1801          * This command cancels the wait time associated with sending an action
1802          * frame. It is only available when %WPA_DRIVER_FLAGS_OFFCHANNEL_TX is
1803          * set in the driver flags.
1804          */
1805         void (*send_action_cancel_wait)(void *priv);
1806
1807         /**
1808          * remain_on_channel - Remain awake on a channel
1809          * @priv: Private driver interface data
1810          * @freq: Frequency (in MHz) of the channel
1811          * @duration: Duration in milliseconds
1812          * Returns: 0 on success, -1 on failure
1813          *
1814          * This command is used to request the driver to remain awake on the
1815          * specified channel for the specified duration and report received
1816          * Action frames with EVENT_RX_ACTION events. Optionally, received
1817          * Probe Request frames may also be requested to be reported by calling
1818          * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
1819          *
1820          * The driver may not be at the requested channel when this function
1821          * returns, i.e., the return code is only indicating whether the
1822          * request was accepted. The caller will need to wait until the
1823          * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
1824          * completed the channel change. This may take some time due to other
1825          * need for the radio and the caller should be prepared to timing out
1826          * its wait since there are no guarantees on when this request can be
1827          * executed.
1828          */
1829         int (*remain_on_channel)(void *priv, unsigned int freq,
1830                                  unsigned int duration);
1831
1832         /**
1833          * cancel_remain_on_channel - Cancel remain-on-channel operation
1834          * @priv: Private driver interface data
1835          *
1836          * This command can be used to cancel a remain-on-channel operation
1837          * before its originally requested duration has passed. This could be
1838          * used, e.g., when remain_on_channel() is used to request extra time
1839          * to receive a response to an Action frame and the response is
1840          * received when there is still unneeded time remaining on the
1841          * remain-on-channel operation.
1842          */
1843         int (*cancel_remain_on_channel)(void *priv);
1844
1845         /**
1846          * probe_req_report - Request Probe Request frames to be indicated
1847          * @priv: Private driver interface data
1848          * @report: Whether to report received Probe Request frames
1849          * Returns: 0 on success, -1 on failure (or if not supported)
1850          *
1851          * This command can be used to request the driver to indicate when
1852          * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
1853          * Since this operation may require extra resources, e.g., due to less
1854          * optimal hardware/firmware RX filtering, many drivers may disable
1855          * Probe Request reporting at least in station mode. This command is
1856          * used to notify the driver when the Probe Request frames need to be
1857          * reported, e.g., during remain-on-channel operations.
1858          */
1859         int (*probe_req_report)(void *priv, int report);
1860
1861         /**
1862          * disable_11b_rates - Set whether IEEE 802.11b rates are used for TX
1863          * @priv: Private driver interface data
1864          * @disabled: Whether IEEE 802.11b rates are disabled
1865          * Returns: 0 on success, -1 on failure (or if not supported)
1866          *
1867          * This command is used to disable IEEE 802.11b rates (1, 2, 5.5, and
1868          * 11 Mbps) as TX rates for data and management frames. This can be
1869          * used to optimize channel use when there is no need to support IEEE
1870          * 802.11b-only devices.
1871          */
1872         int (*disable_11b_rates)(void *priv, int disabled);
1873
1874         /**
1875          * deinit_ap - Deinitialize AP mode
1876          * @priv: Private driver interface data
1877          * Returns: 0 on success, -1 on failure (or if not supported)
1878          *
1879          * This optional function can be used to disable AP mode related
1880          * configuration and change the driver mode to station mode to allow
1881          * normal station operations like scanning to be completed.
1882          */
1883         int (*deinit_ap)(void *priv);
1884
1885         /**
1886          * suspend - Notification on system suspend/hibernate event
1887          * @priv: Private driver interface data
1888          */
1889         void (*suspend)(void *priv);
1890
1891         /**
1892          * resume - Notification on system resume/thaw event
1893          * @priv: Private driver interface data
1894          */
1895         void (*resume)(void *priv);
1896
1897         /**
1898          * signal_monitor - Set signal monitoring parameters
1899          * @priv: Private driver interface data
1900          * @threshold: Threshold value for signal change events; 0 = disabled
1901          * @hysteresis: Minimum change in signal strength before indicating a
1902          *      new event
1903          * Returns: 0 on success, -1 on failure (or if not supported)
1904          *
1905          * This function can be used to configure monitoring of signal strength
1906          * with the current AP. Whenever signal strength drops below the
1907          * %threshold value or increases above it, EVENT_SIGNAL_CHANGE event
1908          * should be generated assuming the signal strength has changed at
1909          * least %hysteresis from the previously indicated signal change event.
1910          */
1911         int (*signal_monitor)(void *priv, int threshold, int hysteresis);
1912
1913         /**
1914          * send_frame - Send IEEE 802.11 frame (testing use only)
1915          * @priv: Private driver interface data
1916          * @data: IEEE 802.11 frame with IEEE 802.11 header
1917          * @data_len: Size of the frame
1918          * @encrypt: Whether to encrypt the frame (if keys are set)
1919          * Returns: 0 on success, -1 on failure
1920          *
1921          * This function is only used for debugging purposes and is not
1922          * required to be implemented for normal operations.
1923          */
1924         int (*send_frame)(void *priv, const u8 *data, size_t data_len,
1925                           int encrypt);
1926
1927         /**
1928          * shared_freq - Get operating frequency of shared interface(s)
1929          * @priv: Private driver interface data
1930          * Returns: Operating frequency in MHz, 0 if no shared operation in
1931          * use, or -1 on failure
1932          *
1933          * This command can be used to request the current operating frequency
1934          * of any virtual interface that shares the same radio to provide
1935          * information for channel selection for other virtual interfaces.
1936          */
1937         int (*shared_freq)(void *priv);
1938
1939         /**
1940          * get_noa - Get current Notice of Absence attribute payload
1941          * @priv: Private driver interface data
1942          * @buf: Buffer for returning NoA
1943          * @buf_len: Buffer length in octets
1944          * Returns: Number of octets used in buf, 0 to indicate no NoA is being
1945          * advertized, or -1 on failure
1946          *
1947          * This function is used to fetch the current Notice of Absence
1948          * attribute value from GO.
1949          */
1950         int (*get_noa)(void *priv, u8 *buf, size_t buf_len);
1951
1952         /**
1953          * set_noa - Set Notice of Absence parameters for GO (testing)
1954          * @priv: Private driver interface data
1955          * @count: Count
1956          * @start: Start time in ms from next TBTT
1957          * @duration: Duration in ms
1958          * Returns: 0 on success or -1 on failure
1959          *
1960          * This function is used to set Notice of Absence parameters for GO. It
1961          * is used only for testing. To disable NoA, all parameters are set to
1962          * 0.
1963          */
1964         int (*set_noa)(void *priv, u8 count, int start, int duration);
1965
1966         /**
1967          * set_p2p_powersave - Set P2P power save options
1968          * @priv: Private driver interface data
1969          * @legacy_ps: 0 = disable, 1 = enable, 2 = maximum PS, -1 = no change
1970          * @opp_ps: 0 = disable, 1 = enable, -1 = no change
1971          * @ctwindow: 0.. = change (msec), -1 = no change
1972          * Returns: 0 on success or -1 on failure
1973          */
1974         int (*set_p2p_powersave)(void *priv, int legacy_ps, int opp_ps,
1975                                  int ctwindow);
1976
1977         /**
1978          * ampdu - Enable/disable aggregation
1979          * @priv: Private driver interface data
1980          * @ampdu: 1/0 = enable/disable A-MPDU aggregation
1981          * Returns: 0 on success or -1 on failure
1982          */
1983         int (*ampdu)(void *priv, int ampdu);
1984
1985         /**
1986          * set_intra_bss - Enables/Disables intra BSS bridging
1987          */
1988         int (*set_intra_bss)(void *priv, int enabled);
1989
1990         /**
1991          * get_radio_name - Get physical radio name for the device
1992          * @priv: Private driver interface data
1993          * Returns: Radio name or %NULL if not known
1994          *
1995          * The returned data must not be modified by the caller. It is assumed
1996          * that any interface that has the same radio name as another is
1997          * sharing the same physical radio. This information can be used to
1998          * share scan results etc. information between the virtual interfaces
1999          * to speed up various operations.
2000          */
2001         const char * (*get_radio_name)(void *priv);
2002
2003         /**
2004          * p2p_find - Start P2P Device Discovery
2005          * @priv: Private driver interface data
2006          * @timeout: Timeout for find operation in seconds or 0 for no timeout
2007          * @type: Device Discovery type (enum p2p_discovery_type)
2008          * Returns: 0 on success, -1 on failure
2009          *
2010          * This function is only used if the driver implements P2P management,
2011          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2012          * struct wpa_driver_capa.
2013          */
2014         int (*p2p_find)(void *priv, unsigned int timeout, int type);
2015
2016         /**
2017          * p2p_stop_find - Stop P2P Device Discovery
2018          * @priv: Private driver interface data
2019          * Returns: 0 on success, -1 on failure
2020          *
2021          * This function is only used if the driver implements P2P management,
2022          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2023          * struct wpa_driver_capa.
2024          */
2025         int (*p2p_stop_find)(void *priv);
2026
2027         /**
2028          * p2p_listen - Start P2P Listen state for specified duration
2029          * @priv: Private driver interface data
2030          * @timeout: Listen state duration in milliseconds
2031          * Returns: 0 on success, -1 on failure
2032          *
2033          * This function can be used to request the P2P module to keep the
2034          * device discoverable on the listen channel for an extended set of
2035          * time. At least in its current form, this is mainly used for testing
2036          * purposes and may not be of much use for normal P2P operations.
2037          *
2038          * This function is only used if the driver implements P2P management,
2039          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2040          * struct wpa_driver_capa.
2041          */
2042         int (*p2p_listen)(void *priv, unsigned int timeout);
2043
2044         /**
2045          * p2p_connect - Start P2P group formation (GO negotiation)
2046          * @priv: Private driver interface data
2047          * @peer_addr: MAC address of the peer P2P client
2048          * @wps_method: enum p2p_wps_method value indicating config method
2049          * @go_intent: Local GO intent value (1..15)
2050          * @own_interface_addr: Intended interface address to use with the
2051          *      group
2052          * @force_freq: The only allowed channel frequency in MHz or 0
2053          * @persistent_group: Whether to create persistent group
2054          * Returns: 0 on success, -1 on failure
2055          *
2056          * This function is only used if the driver implements P2P management,
2057          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2058          * struct wpa_driver_capa.
2059          */
2060         int (*p2p_connect)(void *priv, const u8 *peer_addr, int wps_method,
2061                            int go_intent, const u8 *own_interface_addr,
2062                            unsigned int force_freq, int persistent_group);
2063
2064         /**
2065          * wps_success_cb - Report successfully completed WPS provisioning
2066          * @priv: Private driver interface data
2067          * @peer_addr: Peer address
2068          * Returns: 0 on success, -1 on failure
2069          *
2070          * This function is used to report successfully completed WPS
2071          * provisioning during group formation in both GO/Registrar and
2072          * client/Enrollee roles.
2073          *
2074          * This function is only used if the driver implements P2P management,
2075          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2076          * struct wpa_driver_capa.
2077          */
2078         int (*wps_success_cb)(void *priv, const u8 *peer_addr);
2079
2080         /**
2081          * p2p_group_formation_failed - Report failed WPS provisioning
2082          * @priv: Private driver interface data
2083          * Returns: 0 on success, -1 on failure
2084          *
2085          * This function is used to report failed group formation. This can
2086          * happen either due to failed WPS provisioning or due to 15 second
2087          * timeout during the provisioning phase.
2088          *
2089          * This function is only used if the driver implements P2P management,
2090          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2091          * struct wpa_driver_capa.
2092          */
2093         int (*p2p_group_formation_failed)(void *priv);
2094
2095         /**
2096          * p2p_set_params - Set P2P parameters
2097          * @priv: Private driver interface data
2098          * @params: P2P parameters
2099          * Returns: 0 on success, -1 on failure
2100          *
2101          * This function is only used if the driver implements P2P management,
2102          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2103          * struct wpa_driver_capa.
2104          */
2105         int (*p2p_set_params)(void *priv, const struct p2p_params *params);
2106
2107         /**
2108          * p2p_prov_disc_req - Send Provision Discovery Request
2109          * @priv: Private driver interface data
2110          * @peer_addr: MAC address of the peer P2P client
2111          * @config_methods: WPS Config Methods value (only one bit set)
2112          * Returns: 0 on success, -1 on failure
2113          *
2114          * This function can be used to request a discovered P2P peer to
2115          * display a PIN (config_methods = WPS_CONFIG_DISPLAY) or be prepared
2116          * to enter a PIN from us (config_methods = WPS_CONFIG_KEYPAD). The
2117          * Provision Discovery Request frame is transmitted once immediately
2118          * and if no response is received, the frame will be sent again
2119          * whenever the target device is discovered during device dsicovery
2120          * (start with a p2p_find() call). Response from the peer is indicated
2121          * with the EVENT_P2P_PROV_DISC_RESPONSE event.
2122          *
2123          * This function is only used if the driver implements P2P management,
2124          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2125          * struct wpa_driver_capa.
2126          */
2127         int (*p2p_prov_disc_req)(void *priv, const u8 *peer_addr,
2128                                  u16 config_methods);
2129
2130         /**
2131          * p2p_sd_request - Schedule a service discovery query
2132          * @priv: Private driver interface data
2133          * @dst: Destination peer or %NULL to apply for all peers
2134          * @tlvs: P2P Service Query TLV(s)
2135          * Returns: Reference to the query or 0 on failure
2136          *
2137          * Response to the query is indicated with the
2138          * EVENT_P2P_SD_RESPONSE driver event.
2139          *
2140          * This function is only used if the driver implements P2P management,
2141          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2142          * struct wpa_driver_capa.
2143          */
2144         u64 (*p2p_sd_request)(void *priv, const u8 *dst,
2145                               const struct wpabuf *tlvs);
2146
2147         /**
2148          * p2p_sd_cancel_request - Cancel a pending service discovery query
2149          * @priv: Private driver interface data
2150          * @req: Query reference from p2p_sd_request()
2151          * Returns: 0 on success, -1 on failure
2152          *
2153          * This function is only used if the driver implements P2P management,
2154          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2155          * struct wpa_driver_capa.
2156          */
2157         int (*p2p_sd_cancel_request)(void *priv, u64 req);
2158
2159         /**
2160          * p2p_sd_response - Send response to a service discovery query
2161          * @priv: Private driver interface data
2162          * @freq: Frequency from EVENT_P2P_SD_REQUEST event
2163          * @dst: Destination address from EVENT_P2P_SD_REQUEST event
2164          * @dialog_token: Dialog token from EVENT_P2P_SD_REQUEST event
2165          * @resp_tlvs: P2P Service Response TLV(s)
2166          * Returns: 0 on success, -1 on failure
2167          *
2168          * This function is called as a response to the request indicated with
2169          * the EVENT_P2P_SD_REQUEST driver event.
2170          *
2171          * This function is only used if the driver implements P2P management,
2172          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2173          * struct wpa_driver_capa.
2174          */
2175         int (*p2p_sd_response)(void *priv, int freq, const u8 *dst,
2176                                u8 dialog_token,
2177                                const struct wpabuf *resp_tlvs);
2178
2179         /**
2180          * p2p_service_update - Indicate a change in local services
2181          * @priv: Private driver interface data
2182          * Returns: 0 on success, -1 on failure
2183          *
2184          * This function needs to be called whenever there is a change in
2185          * availability of the local services. This will increment the
2186          * Service Update Indicator value which will be used in SD Request and
2187          * Response frames.
2188          *
2189          * This function is only used if the driver implements P2P management,
2190          * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
2191          * struct wpa_driver_capa.
2192          */
2193         int (*p2p_service_update)(void *priv);
2194
2195         /**
2196          * p2p_reject - Reject peer device (explicitly block connections)
2197          * @priv: Private driver interface data
2198          * @addr: MAC address of the peer
2199          * Returns: 0 on success, -1 on failure
2200          */
2201         int (*p2p_reject)(void *priv, const u8 *addr);
2202
2203         /**
2204          * p2p_invite - Invite a P2P Device into a group
2205          * @priv: Private driver interface data
2206          * @peer: Device Address of the peer P2P Device
2207          * @role: Local role in the group
2208          * @bssid: Group BSSID or %NULL if not known
2209          * @ssid: Group SSID
2210          * @ssid_len: Length of ssid in octets
2211          * @go_dev_addr: Forced GO Device Address or %NULL if none
2212          * @persistent_group: Whether this is to reinvoke a persistent group
2213          * Returns: 0 on success, -1 on failure
2214          */
2215         int (*p2p_invite)(void *priv, const u8 *peer, int role,
2216                           const u8 *bssid, const u8 *ssid, size_t ssid_len,
2217                           const u8 *go_dev_addr, int persistent_group);
2218
2219         /**
2220          * send_tdls_mgmt - for sending TDLS management packets
2221          * @priv: private driver interface data
2222          * @dst: Destination (peer) MAC address
2223          * @action_code: TDLS action code for the mssage
2224          * @dialog_token: Dialog Token to use in the message (if needed)
2225          * @status_code: Status Code or Reason Code to use (if needed)
2226          * @buf: TDLS IEs to add to the message
2227          * @len: Length of buf in octets
2228          * Returns: 0 on success, -1 on failure
2229          *
2230          * This optional function can be used to send packet to driver which is
2231          * responsible for receiving and sending all TDLS packets.
2232          */
2233         int (*send_tdls_mgmt)(void *priv, const u8 *dst, u8 action_code,
2234                               u8 dialog_token, u16 status_code,
2235                               const u8 *buf, size_t len);
2236
2237         int (*tdls_oper)(void *priv, enum tdls_oper oper, const u8 *peer);
2238
2239         /**
2240          * signal_poll - Get current connection information
2241          * @priv: Private driver interface data
2242          * @signal_info: Connection info structure
2243          */
2244         int (*signal_poll)(void *priv, struct wpa_signal_info *signal_info);
2245
2246         /**
2247          * set_authmode - Set authentication algorithm(s) for static WEP
2248          * @priv: Private driver interface data
2249          * @authmode: 1=Open System, 2=Shared Key, 3=both
2250          * Returns: 0 on success, -1 on failure
2251          *
2252          * This function can be used to set authentication algorithms for AP
2253          * mode when static WEP is used. If the driver uses user space MLME/SME
2254          * implementation, there is no need to implement this function.
2255          */
2256         int (*set_authmode)(void *priv, int authmode);
2257 };
2258
2259
2260 /**
2261  * enum wpa_event_type - Event type for wpa_supplicant_event() calls
2262  */
2263 enum wpa_event_type {
2264         /**
2265          * EVENT_ASSOC - Association completed
2266          *
2267          * This event needs to be delivered when the driver completes IEEE
2268          * 802.11 association or reassociation successfully.
2269          * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
2270          * after this event has been generated. In addition, optional
2271          * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
2272          * more information about the association. If the driver interface gets
2273          * both of these events at the same time, it can also include the
2274          * assoc_info data in EVENT_ASSOC call.
2275          */
2276         EVENT_ASSOC,
2277
2278         /**
2279          * EVENT_DISASSOC - Association lost
2280          *
2281          * This event should be called when association is lost either due to
2282          * receiving deauthenticate or disassociate frame from the AP or when
2283          * sending either of these frames to the current AP. If the driver
2284          * supports separate deauthentication event, EVENT_DISASSOC should only
2285          * be used for disassociation and EVENT_DEAUTH for deauthentication.
2286          * In AP mode, union wpa_event_data::disassoc_info is required.
2287          */
2288         EVENT_DISASSOC,
2289
2290         /**
2291          * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
2292          *
2293          * This event must be delivered when a Michael MIC error is detected by
2294          * the local driver. Additional data for event processing is
2295          * provided with union wpa_event_data::michael_mic_failure. This
2296          * information is used to request new encyption key and to initiate
2297          * TKIP countermeasures if needed.
2298          */
2299         EVENT_MICHAEL_MIC_FAILURE,
2300
2301         /**
2302          * EVENT_SCAN_RESULTS - Scan results available
2303          *
2304          * This event must be called whenever scan results are available to be
2305          * fetched with struct wpa_driver_ops::get_scan_results(). This event
2306          * is expected to be used some time after struct wpa_driver_ops::scan()
2307          * is called. If the driver provides an unsolicited event when the scan
2308          * has been completed, this event can be used to trigger
2309          * EVENT_SCAN_RESULTS call. If such event is not available from the
2310          * driver, the driver wrapper code is expected to use a registered
2311          * timeout to generate EVENT_SCAN_RESULTS call after the time that the
2312          * scan is expected to be completed. Optional information about
2313          * completed scan can be provided with union wpa_event_data::scan_info.
2314          */
2315         EVENT_SCAN_RESULTS,
2316
2317         /**
2318          * EVENT_ASSOCINFO - Report optional extra information for association
2319          *
2320          * This event can be used to report extra association information for
2321          * EVENT_ASSOC processing. This extra information includes IEs from
2322          * association frames and Beacon/Probe Response frames in union
2323          * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
2324          * EVENT_ASSOC. Alternatively, the driver interface can include
2325          * assoc_info data in the EVENT_ASSOC call if it has all the
2326          * information available at the same point.
2327          */
2328         EVENT_ASSOCINFO,
2329
2330         /**
2331          * EVENT_INTERFACE_STATUS - Report interface status changes
2332          *
2333          * This optional event can be used to report changes in interface
2334          * status (interface added/removed) using union
2335          * wpa_event_data::interface_status. This can be used to trigger
2336          * wpa_supplicant to stop and re-start processing for the interface,
2337          * e.g., when a cardbus card is ejected/inserted.
2338          */
2339         EVENT_INTERFACE_STATUS,
2340
2341         /**
2342          * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
2343          *
2344          * This event can be used to inform wpa_supplicant about candidates for
2345          * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
2346          * for scan request (ap_scan=2 mode), this event is required for
2347          * pre-authentication. If wpa_supplicant is performing scan request
2348          * (ap_scan=1), this event is optional since scan results can be used
2349          * to add pre-authentication candidates. union
2350          * wpa_event_data::pmkid_candidate is used to report the BSSID of the
2351          * candidate and priority of the candidate, e.g., based on the signal
2352          * strength, in order to try to pre-authenticate first with candidates
2353          * that are most likely targets for re-association.
2354          *
2355          * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
2356          * on the candidate list. In addition, it can be called for the current
2357          * AP and APs that have existing PMKSA cache entries. wpa_supplicant
2358          * will automatically skip pre-authentication in cases where a valid
2359          * PMKSA exists. When more than one candidate exists, this event should
2360          * be generated once for each candidate.
2361          *
2362          * Driver will be notified about successful pre-authentication with
2363          * struct wpa_driver_ops::add_pmkid() calls.
2364          */
2365         EVENT_PMKID_CANDIDATE,
2366
2367         /**
2368          * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
2369          *
2370          * This event can be used to inform wpa_supplicant about desire to set
2371          * up secure direct link connection between two stations as defined in
2372          * IEEE 802.11e with a new PeerKey mechanism that replaced the original
2373          * STAKey negotiation. The caller will need to set peer address for the
2374          * event.
2375          */
2376         EVENT_STKSTART,
2377
2378         /**
2379          * EVENT_TDLS - Request TDLS operation
2380          *
2381          * This event can be used to request a TDLS operation to be performed.
2382          */
2383         EVENT_TDLS,
2384
2385         /**
2386          * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
2387          *
2388          * The driver is expected to report the received FT IEs from
2389          * FT authentication sequence from the AP. The FT IEs are included in
2390          * the extra information in union wpa_event_data::ft_ies.
2391          */
2392         EVENT_FT_RESPONSE,
2393
2394         /**
2395          * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
2396          *
2397          * The driver can use this event to inform wpa_supplicant about a STA
2398          * in an IBSS with which protected frames could be exchanged. This
2399          * event starts RSN authentication with the other STA to authenticate
2400          * the STA and set up encryption keys with it.
2401          */
2402         EVENT_IBSS_RSN_START,
2403
2404         /**
2405          * EVENT_AUTH - Authentication result
2406          *
2407          * This event should be called when authentication attempt has been
2408          * completed. This is only used if the driver supports separate
2409          * authentication step (struct wpa_driver_ops::authenticate).
2410          * Information about authentication result is included in
2411          * union wpa_event_data::auth.
2412          */
2413         EVENT_AUTH,
2414
2415         /**
2416          * EVENT_DEAUTH - Authentication lost
2417          *
2418          * This event should be called when authentication is lost either due
2419          * to receiving deauthenticate frame from the AP or when sending that
2420          * frame to the current AP.
2421          * In AP mode, union wpa_event_data::deauth_info is required.
2422          */
2423         EVENT_DEAUTH,
2424
2425         /**
2426          * EVENT_ASSOC_REJECT - Association rejected
2427          *
2428          * This event should be called when (re)association attempt has been
2429          * rejected by the AP. Information about the association response is
2430          * included in union wpa_event_data::assoc_reject.
2431          */
2432         EVENT_ASSOC_REJECT,
2433
2434         /**
2435          * EVENT_AUTH_TIMED_OUT - Authentication timed out
2436          */
2437         EVENT_AUTH_TIMED_OUT,
2438
2439         /**
2440          * EVENT_ASSOC_TIMED_OUT - Association timed out
2441          */
2442         EVENT_ASSOC_TIMED_OUT,
2443
2444         /**
2445          * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
2446          */
2447         EVENT_FT_RRB_RX,
2448
2449         /**
2450          * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
2451          */
2452         EVENT_WPS_BUTTON_PUSHED,
2453
2454         /**
2455          * EVENT_TX_STATUS - Report TX status
2456          */
2457         EVENT_TX_STATUS,
2458
2459         /**
2460          * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
2461          */
2462         EVENT_RX_FROM_UNKNOWN,
2463
2464         /**
2465          * EVENT_RX_MGMT - Report RX of a management frame
2466          */
2467         EVENT_RX_MGMT,
2468
2469         /**
2470          * EVENT_RX_ACTION - Action frame received
2471          *
2472          * This event is used to indicate when an Action frame has been
2473          * received. Information about the received frame is included in
2474          * union wpa_event_data::rx_action.
2475          */
2476         EVENT_RX_ACTION,
2477
2478         /**
2479          * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
2480          *
2481          * This event is used to indicate when the driver has started the
2482          * requested remain-on-channel duration. Information about the
2483          * operation is included in union wpa_event_data::remain_on_channel.
2484          */
2485         EVENT_REMAIN_ON_CHANNEL,
2486
2487         /**
2488          * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
2489          *
2490          * This event is used to indicate when the driver has completed
2491          * remain-on-channel duration, i.e., may noot be available on the
2492          * requested channel anymore. Information about the
2493          * operation is included in union wpa_event_data::remain_on_channel.
2494          */
2495         EVENT_CANCEL_REMAIN_ON_CHANNEL,
2496
2497         /**
2498          * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
2499          *
2500          * This event is used only by driver_test.c and userspace MLME.
2501          */
2502         EVENT_MLME_RX,
2503
2504         /**
2505          * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
2506          *
2507          * This event is used to indicate when a Probe Request frame has been
2508          * received. Information about the received frame is included in
2509          * union wpa_event_data::rx_probe_req. The driver is required to report
2510          * these events only after successfully completed probe_req_report()
2511          * commands to request the events (i.e., report parameter is non-zero)
2512          * in station mode. In AP mode, Probe Request frames should always be
2513          * reported.
2514          */
2515         EVENT_RX_PROBE_REQ,
2516
2517         /**
2518          * EVENT_NEW_STA - New wired device noticed
2519          *
2520          * This event is used to indicate that a new device has been detected
2521          * in a network that does not use association-like functionality (i.e.,
2522          * mainly wired Ethernet). This can be used to start EAPOL
2523          * authenticator when receiving a frame from a device. The address of
2524          * the device is included in union wpa_event_data::new_sta.
2525          */
2526         EVENT_NEW_STA,
2527
2528         /**
2529          * EVENT_EAPOL_RX - Report received EAPOL frame
2530          *
2531          * When in AP mode with hostapd, this event is required to be used to
2532          * deliver the receive EAPOL frames from the driver. With
2533          * %wpa_supplicant, this event is used only if the send_eapol() handler
2534          * is used to override the use of l2_packet for EAPOL frame TX.
2535          */
2536         EVENT_EAPOL_RX,
2537
2538         /**
2539          * EVENT_SIGNAL_CHANGE - Indicate change in signal strength
2540          *
2541          * This event is used to indicate changes in the signal strength
2542          * observed in frames received from the current AP if signal strength
2543          * monitoring has been enabled with signal_monitor().
2544          */
2545         EVENT_SIGNAL_CHANGE,
2546
2547         /**
2548          * EVENT_INTERFACE_ENABLED - Notify that interface was enabled
2549          *
2550          * This event is used to indicate that the interface was enabled after
2551          * having been previously disabled, e.g., due to rfkill.
2552          */
2553         EVENT_INTERFACE_ENABLED,
2554
2555         /**
2556          * EVENT_INTERFACE_DISABLED - Notify that interface was disabled
2557          *
2558          * This event is used to indicate that the interface was disabled,
2559          * e.g., due to rfkill.
2560          */
2561         EVENT_INTERFACE_DISABLED,
2562
2563         /**
2564          * EVENT_CHANNEL_LIST_CHANGED - Channel list changed
2565          *
2566          * This event is used to indicate that the channel list has changed,
2567          * e.g., because of a regulatory domain change triggered by scan
2568          * results including an AP advertising a country code.
2569          */
2570         EVENT_CHANNEL_LIST_CHANGED,
2571
2572         /**
2573          * EVENT_INTERFACE_UNAVAILABLE - Notify that interface is unavailable
2574          *
2575          * This event is used to indicate that the driver cannot maintain this
2576          * interface in its operation mode anymore. The most likely use for
2577          * this is to indicate that AP mode operation is not available due to
2578          * operating channel would need to be changed to a DFS channel when
2579          * the driver does not support radar detection and another virtual
2580          * interfaces caused the operating channel to change. Other similar
2581          * resource conflicts could also trigger this for station mode
2582          * interfaces.
2583          */
2584         EVENT_INTERFACE_UNAVAILABLE,
2585
2586         /**
2587          * EVENT_BEST_CHANNEL
2588          *
2589          * Driver generates this event whenever it detects a better channel
2590          * (e.g., based on RSSI or channel use). This information can be used
2591          * to improve channel selection for a new AP/P2P group.
2592          */
2593         EVENT_BEST_CHANNEL,
2594
2595         /**
2596          * EVENT_UNPROT_DEAUTH - Unprotected Deauthentication frame received
2597          *
2598          * This event should be called when a Deauthentication frame is dropped
2599          * due to it not being protected (MFP/IEEE 802.11w).
2600          * union wpa_event_data::unprot_deauth is required to provide more
2601          * details of the frame.
2602          */
2603         EVENT_UNPROT_DEAUTH,
2604
2605         /**
2606          * EVENT_UNPROT_DISASSOC - Unprotected Disassociation frame received
2607          *
2608          * This event should be called when a Disassociation frame is dropped
2609          * due to it not being protected (MFP/IEEE 802.11w).
2610          * union wpa_event_data::unprot_disassoc is required to provide more
2611          * details of the frame.
2612          */
2613         EVENT_UNPROT_DISASSOC,
2614
2615         /**
2616          * EVENT_STATION_LOW_ACK
2617          *
2618          * Driver generates this event whenever it detected that a particular
2619          * station was lost. Detection can be through massive transmission
2620          * failures for example.
2621          */
2622         EVENT_STATION_LOW_ACK,
2623
2624         /**
2625          * EVENT_P2P_DEV_FOUND - Report a discovered P2P device
2626          *
2627          * This event is used only if the driver implements P2P management
2628          * internally. Event data is stored in
2629          * union wpa_event_data::p2p_dev_found.
2630          */
2631         EVENT_P2P_DEV_FOUND,
2632
2633         /**
2634          * EVENT_P2P_GO_NEG_REQ_RX - Report reception of GO Negotiation Request
2635          *
2636          * This event is used only if the driver implements P2P management
2637          * internally. Event data is stored in
2638          * union wpa_event_data::p2p_go_neg_req_rx.
2639          */
2640         EVENT_P2P_GO_NEG_REQ_RX,
2641
2642         /**
2643          * EVENT_P2P_GO_NEG_COMPLETED - Report completion of GO Negotiation
2644          *
2645          * This event is used only if the driver implements P2P management
2646          * internally. Event data is stored in
2647          * union wpa_event_data::p2p_go_neg_completed.
2648          */
2649         EVENT_P2P_GO_NEG_COMPLETED,
2650
2651         EVENT_P2P_PROV_DISC_REQUEST,
2652         EVENT_P2P_PROV_DISC_RESPONSE,
2653         EVENT_P2P_SD_REQUEST,
2654         EVENT_P2P_SD_RESPONSE,
2655
2656         /**
2657          * EVENT_IBSS_PEER_LOST - IBSS peer not reachable anymore
2658          */
2659         EVENT_IBSS_PEER_LOST
2660 };
2661
2662
2663 /**
2664  * union wpa_event_data - Additional data for wpa_supplicant_event() calls
2665  */
2666 union wpa_event_data {
2667         /**
2668          * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
2669          *
2670          * This structure is optional for EVENT_ASSOC calls and required for
2671          * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
2672          * driver interface does not need to generate separate EVENT_ASSOCINFO
2673          * calls.
2674          */
2675         struct assoc_info {
2676                 /**
2677                  * reassoc - Flag to indicate association or reassociation
2678                  */
2679                 int reassoc;
2680
2681                 /**
2682                  * req_ies - (Re)Association Request IEs
2683                  *
2684                  * If the driver generates WPA/RSN IE, this event data must be
2685                  * returned for WPA handshake to have needed information. If
2686                  * wpa_supplicant-generated WPA/RSN IE is used, this
2687                  * information event is optional.
2688                  *
2689                  * This should start with the first IE (fixed fields before IEs
2690                  * are not included).
2691                  */
2692                 const u8 *req_ies;
2693
2694                 /**
2695                  * req_ies_len - Length of req_ies in bytes
2696                  */
2697                 size_t req_ies_len;
2698
2699                 /**
2700                  * resp_ies - (Re)Association Response IEs
2701                  *
2702                  * Optional association data from the driver. This data is not
2703                  * required WPA, but may be useful for some protocols and as
2704                  * such, should be reported if this is available to the driver
2705                  * interface.
2706                  *
2707                  * This should start with the first IE (fixed fields before IEs
2708                  * are not included).
2709                  */
2710                 const u8 *resp_ies;
2711
2712                 /**
2713                  * resp_ies_len - Length of resp_ies in bytes
2714                  */
2715                 size_t resp_ies_len;
2716
2717                 /**
2718                  * beacon_ies - Beacon or Probe Response IEs
2719                  *
2720                  * Optional Beacon/ProbeResp data: IEs included in Beacon or
2721                  * Probe Response frames from the current AP (i.e., the one
2722                  * that the client just associated with). This information is
2723                  * used to update WPA/RSN IE for the AP. If this field is not
2724                  * set, the results from previous scan will be used. If no
2725                  * data for the new AP is found, scan results will be requested
2726                  * again (without scan request). At this point, the driver is
2727                  * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
2728                  * used).
2729                  *
2730                  * This should start with the first IE (fixed fields before IEs
2731                  * are not included).
2732                  */
2733                 const u8 *beacon_ies;
2734
2735                 /**
2736                  * beacon_ies_len - Length of beacon_ies */
2737                 size_t beacon_ies_len;
2738
2739                 /**
2740                  * freq - Frequency of the operational channel in MHz
2741                  */
2742                 unsigned int freq;
2743
2744                 /**
2745                  * addr - Station address (for AP mode)
2746                  */
2747                 const u8 *addr;
2748         } assoc_info;
2749
2750         /**
2751          * struct disassoc_info - Data for EVENT_DISASSOC events
2752          */
2753         struct disassoc_info {
2754                 /**
2755                  * addr - Station address (for AP mode)
2756                  */
2757                 const u8 *addr;
2758
2759                 /**
2760                  * reason_code - Reason Code (host byte order) used in
2761                  *      Deauthentication frame
2762                  */
2763                 u16 reason_code;
2764
2765                 /**
2766                  * ie - Optional IE(s) in Disassociation frame
2767                  */
2768                 const u8 *ie;
2769
2770                 /**
2771                  * ie_len - Length of ie buffer in octets
2772                  */
2773                 size_t ie_len;
2774         } disassoc_info;
2775
2776         /**
2777          * struct deauth_info - Data for EVENT_DEAUTH events
2778          */
2779         struct deauth_info {
2780                 /**
2781                  * addr - Station address (for AP mode)
2782                  */
2783                 const u8 *addr;
2784
2785                 /**
2786                  * reason_code - Reason Code (host byte order) used in
2787                  *      Deauthentication frame
2788                  */
2789                 u16 reason_code;
2790
2791                 /**
2792                  * ie - Optional IE(s) in Deauthentication frame
2793                  */
2794                 const u8 *ie;
2795
2796                 /**
2797                  * ie_len - Length of ie buffer in octets
2798                  */
2799                 size_t ie_len;
2800         } deauth_info;
2801
2802         /**
2803          * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
2804          */
2805         struct michael_mic_failure {
2806                 int unicast;
2807                 const u8 *src;
2808         } michael_mic_failure;
2809
2810         /**
2811          * struct interface_status - Data for EVENT_INTERFACE_STATUS
2812          */
2813         struct interface_status {
2814                 char ifname[100];
2815                 enum {
2816                         EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
2817                 } ievent;
2818         } interface_status;
2819
2820         /**
2821          * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
2822          */
2823         struct pmkid_candidate {
2824                 /** BSSID of the PMKID candidate */
2825                 u8 bssid[ETH_ALEN];
2826                 /** Smaller the index, higher the priority */
2827                 int index;
2828                 /** Whether RSN IE includes pre-authenticate flag */
2829                 int preauth;
2830         } pmkid_candidate;
2831
2832         /**
2833          * struct stkstart - Data for EVENT_STKSTART
2834          */
2835         struct stkstart {
2836                 u8 peer[ETH_ALEN];
2837         } stkstart;
2838
2839         /**
2840          * struct tdls - Data for EVENT_TDLS
2841          */
2842         struct tdls {
2843                 u8 peer[ETH_ALEN];
2844                 enum {
2845                         TDLS_REQUEST_SETUP,
2846                         TDLS_REQUEST_TEARDOWN
2847                 } oper;
2848                 u16 reason_code; /* for teardown */
2849         } tdls;
2850
2851         /**
2852          * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
2853          *
2854          * During FT (IEEE 802.11r) authentication sequence, the driver is
2855          * expected to use this event to report received FT IEs (MDIE, FTIE,
2856          * RSN IE, TIE, possible resource request) to the supplicant. The FT
2857          * IEs for the next message will be delivered through the
2858          * struct wpa_driver_ops::update_ft_ies() callback.
2859          */
2860         struct ft_ies {
2861                 const u8 *ies;
2862                 size_t ies_len;
2863                 int ft_action;
2864                 u8 target_ap[ETH_ALEN];
2865                 /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
2866                 const u8 *ric_ies;
2867                 /** Length of ric_ies buffer in octets */
2868                 size_t ric_ies_len;
2869         } ft_ies;
2870
2871         /**
2872          * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
2873          */
2874         struct ibss_rsn_start {
2875                 u8 peer[ETH_ALEN];
2876         } ibss_rsn_start;
2877
2878         /**
2879          * struct auth_info - Data for EVENT_AUTH events
2880          */
2881         struct auth_info {
2882                 u8 peer[ETH_ALEN];
2883                 u16 auth_type;
2884                 u16 status_code;
2885                 const u8 *ies;
2886                 size_t ies_len;
2887         } auth;
2888
2889         /**
2890          * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
2891          */
2892         struct assoc_reject {
2893                 /**
2894                  * bssid - BSSID of the AP that rejected association
2895                  */
2896                 const u8 *bssid;
2897
2898                 /**
2899                  * resp_ies - (Re)Association Response IEs
2900                  *
2901                  * Optional association data from the driver. This data is not
2902                  * required WPA, but may be useful for some protocols and as
2903                  * such, should be reported if this is available to the driver
2904                  * interface.
2905                  *
2906                  * This should start with the first IE (fixed fields before IEs
2907                  * are not included).
2908                  */
2909                 const u8 *resp_ies;
2910
2911                 /**
2912                  * resp_ies_len - Length of resp_ies in bytes
2913                  */
2914                 size_t resp_ies_len;
2915
2916                 /**
2917                  * status_code - Status Code from (Re)association Response
2918                  */
2919                 u16 status_code;
2920         } assoc_reject;
2921
2922         struct timeout_event {
2923                 u8 addr[ETH_ALEN];
2924         } timeout_event;
2925
2926         /**
2927          * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
2928          */
2929         struct ft_rrb_rx {
2930                 const u8 *src;
2931                 const u8 *data;
2932                 size_t data_len;
2933         } ft_rrb_rx;
2934
2935         /**
2936          * struct tx_status - Data for EVENT_TX_STATUS events
2937          */
2938         struct tx_status {
2939                 u16 type;
2940                 u16 stype;
2941                 const u8 *dst;
2942                 const u8 *data;
2943                 size_t data_len;
2944                 int ack;
2945         } tx_status;
2946
2947         /**
2948          * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
2949          */
2950         struct rx_from_unknown {
2951                 const u8 *frame;
2952                 size_t len;
2953         } rx_from_unknown;
2954
2955         /**
2956          * struct rx_mgmt - Data for EVENT_RX_MGMT events
2957          */
2958         struct rx_mgmt {
2959                 const u8 *frame;
2960                 size_t frame_len;
2961                 u32 datarate;
2962                 u32 ssi_signal;
2963         } rx_mgmt;
2964
2965         /**
2966          * struct rx_action - Data for EVENT_RX_ACTION events
2967          */
2968         struct rx_action {
2969                 /**
2970                  * da - Destination address of the received Action frame
2971                  */
2972                 const u8 *da;
2973
2974                 /**
2975                  * sa - Source address of the received Action frame
2976                  */
2977                 const u8 *sa;
2978
2979                 /**
2980                  * bssid - Address 3 of the received Action frame
2981                  */
2982                 const u8 *bssid;
2983
2984                 /**
2985                  * category - Action frame category
2986                  */
2987                 u8 category;
2988
2989                 /**
2990                  * data - Action frame body after category field
2991                  */
2992                 const u8 *data;
2993
2994                 /**
2995                  * len - Length of data in octets
2996                  */
2997                 size_t len;
2998
2999                 /**
3000                  * freq - Frequency (in MHz) on which the frame was received
3001                  */
3002                 int freq;
3003         } rx_action;
3004
3005         /**
3006          * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
3007          *
3008          * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
3009          */
3010         struct remain_on_channel {
3011                 /**
3012                  * freq - Channel frequency in MHz
3013                  */
3014                 unsigned int freq;
3015
3016                 /**
3017                  * duration - Duration to remain on the channel in milliseconds
3018                  */
3019                 unsigned int duration;
3020         } remain_on_channel;
3021
3022         /**
3023          * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
3024          * @aborted: Whether the scan was aborted
3025          * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
3026          * @num_freqs: Number of entries in freqs array
3027          * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
3028          *      SSID)
3029          * @num_ssids: Number of entries in ssids array
3030          */
3031         struct scan_info {
3032                 int aborted;
3033                 const int *freqs;
3034                 size_t num_freqs;
3035                 struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
3036                 size_t num_ssids;
3037         } scan_info;
3038
3039         /**
3040          * struct mlme_rx - Data for EVENT_MLME_RX events
3041          */
3042         struct mlme_rx {
3043                 const u8 *buf;
3044                 size_t len;
3045                 int freq;
3046                 int channel;
3047                 int ssi;
3048         } mlme_rx;
3049
3050         /**
3051          * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
3052          */
3053         struct rx_probe_req {
3054                 /**
3055                  * sa - Source address of the received Probe Request frame
3056                  */
3057                 const u8 *sa;
3058
3059                 /**
3060                  * ie - IEs from the Probe Request body
3061                  */
3062                 const u8 *ie;
3063
3064                 /**
3065                  * ie_len - Length of ie buffer in octets
3066                  */
3067                 size_t ie_len;
3068         } rx_probe_req;
3069
3070         /**
3071          * struct new_sta - Data for EVENT_NEW_STA events
3072          */
3073         struct new_sta {
3074                 const u8 *addr;
3075         } new_sta;
3076
3077         /**
3078          * struct eapol_rx - Data for EVENT_EAPOL_RX events
3079          */
3080         struct eapol_rx {
3081                 const u8 *src;
3082                 const u8 *data;
3083                 size_t data_len;
3084         } eapol_rx;
3085
3086         /**
3087          * signal_change - Data for EVENT_SIGNAL_CHANGE events
3088          */
3089         struct wpa_signal_info signal_change;
3090
3091         /**
3092          * struct best_channel - Data for EVENT_BEST_CHANNEL events
3093          * @freq_24: Best 2.4 GHz band channel frequency in MHz
3094          * @freq_5: Best 5 GHz band channel frequency in MHz
3095          * @freq_overall: Best channel frequency in MHz
3096          *
3097          * 0 can be used to indicate no preference in either band.
3098          */
3099         struct best_channel {
3100                 int freq_24;
3101                 int freq_5;
3102                 int freq_overall;
3103         } best_chan;
3104
3105         struct unprot_deauth {
3106                 const u8 *sa;
3107                 const u8 *da;
3108                 u16 reason_code;
3109         } unprot_deauth;
3110
3111         struct unprot_disassoc {
3112                 const u8 *sa;
3113                 const u8 *da;
3114                 u16 reason_code;
3115         } unprot_disassoc;
3116
3117         /**
3118          * struct low_ack - Data for EVENT_STATION_LOW_ACK events
3119          * @addr: station address
3120          */
3121         struct low_ack {
3122                 u8 addr[ETH_ALEN];
3123         } low_ack;
3124
3125         /**
3126          * struct p2p_dev_found - Data for EVENT_P2P_DEV_FOUND
3127          */
3128         struct p2p_dev_found {
3129                 const u8 *addr;
3130                 const u8 *dev_addr;
3131                 const u8 *pri_dev_type;
3132                 const char *dev_name;
3133                 u16 config_methods;
3134                 u8 dev_capab;
3135                 u8 group_capab;
3136         } p2p_dev_found;
3137
3138         /**
3139          * struct p2p_go_neg_req_rx - Data for EVENT_P2P_GO_NEG_REQ_RX
3140          */
3141         struct p2p_go_neg_req_rx {
3142                 const u8 *src;
3143                 u16 dev_passwd_id;
3144         } p2p_go_neg_req_rx;
3145
3146         /**
3147          * struct p2p_go_neg_completed - Data for EVENT_P2P_GO_NEG_COMPLETED
3148          */
3149         struct p2p_go_neg_completed {
3150                 struct p2p_go_neg_results *res;
3151         } p2p_go_neg_completed;
3152
3153         struct p2p_prov_disc_req {
3154                 const u8 *peer;
3155                 u16 config_methods;
3156                 const u8 *dev_addr;
3157                 const u8 *pri_dev_type;
3158                 const char *dev_name;
3159                 u16 supp_config_methods;
3160                 u8 dev_capab;
3161                 u8 group_capab;
3162         } p2p_prov_disc_req;
3163
3164         struct p2p_prov_disc_resp {
3165                 const u8 *peer;
3166                 u16 config_methods;
3167         } p2p_prov_disc_resp;
3168
3169         struct p2p_sd_req {
3170                 int freq;
3171                 const u8 *sa;
3172                 u8 dialog_token;
3173                 u16 update_indic;
3174                 const u8 *tlvs;
3175                 size_t tlvs_len;
3176         } p2p_sd_req;
3177
3178         struct p2p_sd_resp {
3179                 const u8 *sa;
3180                 u16 update_indic;
3181                 const u8 *tlvs;
3182                 size_t tlvs_len;
3183         } p2p_sd_resp;
3184
3185         /**
3186          * struct ibss_peer_lost - Data for EVENT_IBSS_PEER_LOST
3187          */
3188         struct ibss_peer_lost {
3189                 u8 peer[ETH_ALEN];
3190         } ibss_peer_lost;
3191 };
3192
3193 /**
3194  * wpa_supplicant_event - Report a driver event for wpa_supplicant
3195  * @ctx: Context pointer (wpa_s); this is the ctx variable registered
3196  *      with struct wpa_driver_ops::init()
3197  * @event: event type (defined above)
3198  * @data: possible extra data for the event
3199  *
3200  * Driver wrapper code should call this function whenever an event is received
3201  * from the driver.
3202  */
3203 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
3204                           union wpa_event_data *data);
3205
3206
3207 /*
3208  * The following inline functions are provided for convenience to simplify
3209  * event indication for some of the common events.
3210  */
3211
3212 static inline void drv_event_assoc(void *ctx, const u8 *addr, const u8 *ie,
3213                                    size_t ielen, int reassoc)
3214 {
3215         union wpa_event_data event;
3216         os_memset(&event, 0, sizeof(event));
3217         event.assoc_info.reassoc = reassoc;
3218         event.assoc_info.req_ies = ie;
3219         event.assoc_info.req_ies_len = ielen;
3220         event.assoc_info.addr = addr;
3221         wpa_supplicant_event(ctx, EVENT_ASSOC, &event);
3222 }
3223
3224 static inline void drv_event_disassoc(void *ctx, const u8 *addr)
3225 {
3226         union wpa_event_data event;
3227         os_memset(&event, 0, sizeof(event));
3228         event.disassoc_info.addr = addr;
3229         wpa_supplicant_event(ctx, EVENT_DISASSOC, &event);
3230 }
3231
3232 static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
3233                                       size_t data_len)
3234 {
3235         union wpa_event_data event;
3236         os_memset(&event, 0, sizeof(event));
3237         event.eapol_rx.src = src;
3238         event.eapol_rx.data = data;
3239         event.eapol_rx.data_len = data_len;
3240         wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
3241 }
3242
3243 #endif /* DRIVER_H */