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