]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/drivers/driver.h
Remove unused rate flags from driver use
[thirdparty/hostap.git] / src / drivers / driver.h
1 /*
2 * WPA Supplicant - driver interface definition
3 * Copyright (c) 2003-2009, 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
15 #ifndef DRIVER_H
16 #define DRIVER_H
17
18 #define WPA_SUPPLICANT_DRIVER_VERSION 4
19
20 #include "common/defs.h"
21
22 #define HOSTAPD_CHAN_DISABLED 0x00000001
23 #define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
24 #define HOSTAPD_CHAN_NO_IBSS 0x00000004
25 #define HOSTAPD_CHAN_RADAR 0x00000008
26
27 struct hostapd_channel_data {
28 short chan; /* channel number (IEEE 802.11) */
29 short freq; /* frequency in MHz */
30 int flag; /* flag for hostapd use (HOSTAPD_CHAN_*) */
31 u8 max_tx_power; /* maximum transmit power in dBm */
32 };
33
34 #define HOSTAPD_RATE_BASIC 0x00000002
35
36 struct hostapd_rate_data {
37 int rate; /* rate in 100 kbps */
38 int flags; /* HOSTAPD_RATE_ flags for internal use */
39 };
40
41 struct hostapd_hw_modes {
42 hostapd_hw_mode mode;
43 int num_channels;
44 struct hostapd_channel_data *channels;
45 int num_rates;
46 struct hostapd_rate_data *rates;
47 u16 ht_capab;
48 u8 mcs_set[16];
49 u8 a_mpdu_params;
50 };
51
52
53 #define AUTH_ALG_OPEN_SYSTEM 0x01
54 #define AUTH_ALG_SHARED_KEY 0x02
55 #define AUTH_ALG_LEAP 0x04
56 #define AUTH_ALG_FT 0x08
57
58 #define IEEE80211_MODE_INFRA 0
59 #define IEEE80211_MODE_IBSS 1
60 #define IEEE80211_MODE_AP 2
61
62 #define IEEE80211_CAP_ESS 0x0001
63 #define IEEE80211_CAP_IBSS 0x0002
64 #define IEEE80211_CAP_PRIVACY 0x0010
65
66 #define WPA_SCAN_QUAL_INVALID BIT(0)
67 #define WPA_SCAN_NOISE_INVALID BIT(1)
68 #define WPA_SCAN_LEVEL_INVALID BIT(2)
69 #define WPA_SCAN_LEVEL_DBM BIT(3)
70 #define WPA_SCAN_AUTHENTICATED BIT(4)
71 #define WPA_SCAN_ASSOCIATED BIT(5)
72
73 /**
74 * struct wpa_scan_res - Scan result for an BSS/IBSS
75 * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
76 * @bssid: BSSID
77 * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
78 * @beacon_int: beacon interval in TUs (host byte order)
79 * @caps: capability information field in host byte order
80 * @qual: signal quality
81 * @noise: noise level
82 * @level: signal level
83 * @tsf: Timestamp
84 * @age: Age of the information in milliseconds (i.e., how many milliseconds
85 * ago the last Beacon or Probe Response frame was received)
86 * @ie_len: length of the following IE field in octets
87 *
88 * This structure is used as a generic format for scan results from the
89 * driver. Each driver interface implementation is responsible for converting
90 * the driver or OS specific scan results into this format.
91 *
92 * If the driver does not support reporting all IEs, the IE data structure is
93 * constructed of the IEs that are available. This field will also need to
94 * include SSID in IE format. All drivers are encouraged to be extended to
95 * report all IEs to make it easier to support future additions.
96 */
97 struct wpa_scan_res {
98 unsigned int flags;
99 u8 bssid[ETH_ALEN];
100 int freq;
101 u16 beacon_int;
102 u16 caps;
103 int qual;
104 int noise;
105 int level;
106 u64 tsf;
107 unsigned int age;
108 size_t ie_len;
109 /* followed by ie_len octets of IEs */
110 };
111
112 /**
113 * struct wpa_scan_results - Scan results
114 * @res: Array of pointers to allocated variable length scan result entries
115 * @num: Number of entries in the scan result array
116 */
117 struct wpa_scan_results {
118 struct wpa_scan_res **res;
119 size_t num;
120 };
121
122 /**
123 * struct wpa_interface_info - Network interface information
124 * @next: Pointer to the next interface or NULL if this is the last one
125 * @ifname: Interface name that can be used with init() or init2()
126 * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
127 * not available
128 * @drv_bame: struct wpa_driver_ops::name (note: unlike other strings, this one
129 * is not an allocated copy, i.e., get_interfaces() caller will not free
130 * this)
131 */
132 struct wpa_interface_info {
133 struct wpa_interface_info *next;
134 char *ifname;
135 char *desc;
136 const char *drv_name;
137 };
138
139 #define WPAS_MAX_SCAN_SSIDS 4
140
141 /**
142 * struct wpa_driver_scan_params - Scan parameters
143 * Data for struct wpa_driver_ops::scan2().
144 */
145 struct wpa_driver_scan_params {
146 /**
147 * ssids - SSIDs to scan for
148 */
149 struct wpa_driver_scan_ssid {
150 /**
151 * ssid - specific SSID to scan for (ProbeReq)
152 * %NULL or zero-length SSID is used to indicate active scan
153 * with wildcard SSID.
154 */
155 const u8 *ssid;
156 /**
157 * ssid_len: Length of the SSID in octets
158 */
159 size_t ssid_len;
160 } ssids[WPAS_MAX_SCAN_SSIDS];
161
162 /**
163 * num_ssids - Number of entries in ssids array
164 * Zero indicates a request for a passive scan.
165 */
166 size_t num_ssids;
167
168 /**
169 * extra_ies - Extra IE(s) to add into Probe Request or %NULL
170 */
171 const u8 *extra_ies;
172
173 /**
174 * extra_ies_len - Length of extra_ies in octets
175 */
176 size_t extra_ies_len;
177
178 /**
179 * freqs - Array of frequencies to scan or %NULL for all frequencies
180 *
181 * The frequency is set in MHz. The array is zero-terminated.
182 */
183 int *freqs;
184 };
185
186 /**
187 * struct wpa_driver_auth_params - Authentication parameters
188 * Data for struct wpa_driver_ops::authenticate().
189 */
190 struct wpa_driver_auth_params {
191 int freq;
192 const u8 *bssid;
193 const u8 *ssid;
194 size_t ssid_len;
195 int auth_alg;
196 const u8 *ie;
197 size_t ie_len;
198 const u8 *wep_key[4];
199 size_t wep_key_len[4];
200 int wep_tx_keyidx;
201 };
202
203 /**
204 * struct wpa_driver_associate_params - Association parameters
205 * Data for struct wpa_driver_ops::associate().
206 */
207 struct wpa_driver_associate_params {
208 /**
209 * bssid - BSSID of the selected AP
210 * This can be %NULL, if ap_scan=2 mode is used and the driver is
211 * responsible for selecting with which BSS to associate. */
212 const u8 *bssid;
213
214 /**
215 * ssid - The selected SSID
216 */
217 const u8 *ssid;
218 size_t ssid_len;
219
220 /**
221 * freq - Frequency of the channel the selected AP is using
222 * Frequency that the selected AP is using (in MHz as
223 * reported in the scan results)
224 */
225 int freq;
226
227 /**
228 * wpa_ie - WPA information element for (Re)Association Request
229 * WPA information element to be included in (Re)Association
230 * Request (including information element id and length). Use
231 * of this WPA IE is optional. If the driver generates the WPA
232 * IE, it can use pairwise_suite, group_suite, and
233 * key_mgmt_suite to select proper algorithms. In this case,
234 * the driver has to notify wpa_supplicant about the used WPA
235 * IE by generating an event that the interface code will
236 * convert into EVENT_ASSOCINFO data (see below).
237 *
238 * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
239 * instead. The driver can determine which version is used by
240 * looking at the first byte of the IE (0xdd for WPA, 0x30 for
241 * WPA2/RSN).
242 *
243 * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
244 */
245 const u8 *wpa_ie;
246 /**
247 * wpa_ie_len - length of the wpa_ie
248 */
249 size_t wpa_ie_len;
250
251 /* The selected pairwise/group cipher and key management
252 * suites. These are usually ignored if @wpa_ie is used. */
253 wpa_cipher pairwise_suite;
254 wpa_cipher group_suite;
255 wpa_key_mgmt key_mgmt_suite;
256
257 /**
258 * auth_alg - Allowed authentication algorithms
259 * Bit field of AUTH_ALG_*
260 */
261 int auth_alg;
262
263 /**
264 * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
265 */
266 int mode;
267
268 /**
269 * wep_key - WEP keys for static WEP configuration
270 */
271 const u8 *wep_key[4];
272
273 /**
274 * wep_key_len - WEP key length for static WEP configuration
275 */
276 size_t wep_key_len[4];
277
278 /**
279 * wep_tx_keyidx - WEP TX key index for static WEP configuration
280 */
281 int wep_tx_keyidx;
282
283 /**
284 * mgmt_frame_protection - IEEE 802.11w management frame protection
285 */
286 enum {
287 NO_MGMT_FRAME_PROTECTION,
288 MGMT_FRAME_PROTECTION_OPTIONAL,
289 MGMT_FRAME_PROTECTION_REQUIRED
290 } mgmt_frame_protection;
291
292 /**
293 * ft_ies - IEEE 802.11r / FT information elements
294 * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
295 * for fast transition, this parameter is set to include the IEs that
296 * are to be sent in the next FT Authentication Request message.
297 * update_ft_ies() handler is called to update the IEs for further
298 * FT messages in the sequence.
299 *
300 * The driver should use these IEs only if the target AP is advertising
301 * the same mobility domain as the one included in the MDIE here.
302 *
303 * In ap_scan=2 mode, the driver can use these IEs when moving to a new
304 * AP after the initial association. These IEs can only be used if the
305 * target AP is advertising support for FT and is using the same MDIE
306 * and SSID as the current AP.
307 *
308 * The driver is responsible for reporting the FT IEs received from the
309 * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
310 * type. update_ft_ies() handler will then be called with the FT IEs to
311 * include in the next frame in the authentication sequence.
312 */
313 const u8 *ft_ies;
314
315 /**
316 * ft_ies_len - Length of ft_ies in bytes
317 */
318 size_t ft_ies_len;
319
320 /**
321 * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
322 *
323 * This value is provided to allow the driver interface easier access
324 * to the current mobility domain. This value is set to %NULL if no
325 * mobility domain is currently active.
326 */
327 const u8 *ft_md;
328
329 /**
330 * passphrase - RSN passphrase for PSK
331 *
332 * This value is made available only for WPA/WPA2-Personal (PSK) and
333 * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
334 * the 8..63 character ASCII passphrase, if available. Please note that
335 * this can be %NULL if passphrase was not used to generate the PSK. In
336 * that case, the psk field must be used to fetch the PSK.
337 */
338 const char *passphrase;
339
340 /**
341 * psk - RSN PSK (alternative for passphrase for PSK)
342 *
343 * This value is made available only for WPA/WPA2-Personal (PSK) and
344 * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
345 * the 32-octet (256-bit) PSK, if available. The driver wrapper should
346 * be prepared to handle %NULL value as an error.
347 */
348 const u8 *psk;
349
350 /**
351 * drop_unencrypted - Enable/disable unencrypted frame filtering
352 *
353 * Configure the driver to drop all non-EAPOL frames (both receive and
354 * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
355 * still be allowed for key negotiation.
356 */
357 int drop_unencrypted;
358
359 /**
360 * prev_bssid - Previously used BSSID in this ESS
361 *
362 * When not %NULL, this is a request to use reassociation instead of
363 * association.
364 */
365 const u8 *prev_bssid;
366 };
367
368 /**
369 * struct wpa_driver_capa - Driver capability information
370 */
371 struct wpa_driver_capa {
372 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
373 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
374 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK 0x00000004
375 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK 0x00000008
376 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE 0x00000010
377 #define WPA_DRIVER_CAPA_KEY_MGMT_FT 0x00000020
378 #define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK 0x00000040
379 unsigned int key_mgmt;
380
381 #define WPA_DRIVER_CAPA_ENC_WEP40 0x00000001
382 #define WPA_DRIVER_CAPA_ENC_WEP104 0x00000002
383 #define WPA_DRIVER_CAPA_ENC_TKIP 0x00000004
384 #define WPA_DRIVER_CAPA_ENC_CCMP 0x00000008
385 unsigned int enc;
386
387 #define WPA_DRIVER_AUTH_OPEN 0x00000001
388 #define WPA_DRIVER_AUTH_SHARED 0x00000002
389 #define WPA_DRIVER_AUTH_LEAP 0x00000004
390 unsigned int auth;
391
392 /* Driver generated WPA/RSN IE */
393 #define WPA_DRIVER_FLAGS_DRIVER_IE 0x00000001
394 /* Driver needs static WEP key setup after association command */
395 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
396 #define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
397 /* Driver takes care of RSN 4-way handshake internally; PMK is configured with
398 * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
399 #define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
400 #define WPA_DRIVER_FLAGS_WIRED 0x00000010
401 /* Driver provides separate commands for authentication and association (SME in
402 * wpa_supplicant). */
403 #define WPA_DRIVER_FLAGS_SME 0x00000020
404 /* Driver supports AP mode */
405 #define WPA_DRIVER_FLAGS_AP 0x00000040
406 /* Driver needs static WEP key setup after association has been completed */
407 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE 0x00000080
408 unsigned int flags;
409
410 int max_scan_ssids;
411 };
412
413
414 struct ieee80211_rx_status {
415 int channel;
416 int ssi;
417 };
418
419
420 struct hostapd_data;
421
422 struct hostap_sta_driver_data {
423 unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
424 unsigned long current_tx_rate;
425 unsigned long inactive_msec;
426 unsigned long flags;
427 unsigned long num_ps_buf_frames;
428 unsigned long tx_retry_failed;
429 unsigned long tx_retry_count;
430 int last_rssi;
431 int last_ack_rssi;
432 };
433
434 struct hostapd_sta_add_params {
435 const u8 *addr;
436 u16 aid;
437 u16 capability;
438 const u8 *supp_rates;
439 size_t supp_rates_len;
440 int flags;
441 u16 listen_interval;
442 const struct ieee80211_ht_capabilities *ht_capabilities;
443 };
444
445 struct hostapd_freq_params {
446 int mode;
447 int freq;
448 int channel;
449 int ht_enabled;
450 int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
451 * secondary channel below primary, 1 = HT40
452 * enabled, secondary channel above primary */
453 };
454
455 enum wpa_driver_if_type {
456 /**
457 * WPA_IF_STATION - Station mode interface
458 */
459 WPA_IF_STATION,
460
461 /**
462 * WPA_IF_AP_VLAN - AP mode VLAN interface
463 *
464 * This interface shares its address and Beacon frame with the main
465 * BSS.
466 */
467 WPA_IF_AP_VLAN,
468
469 /**
470 * WPA_IF_AP_BSS - AP mode BSS interface
471 *
472 * This interface has its own address and Beacon frame.
473 */
474 WPA_IF_AP_BSS,
475 };
476
477 struct wpa_init_params {
478 const u8 *bssid;
479 const char *ifname;
480 const u8 *ssid;
481 size_t ssid_len;
482 const char *test_socket;
483 int use_pae_group_addr;
484 char **bridge;
485 size_t num_bridge;
486
487 u8 *own_addr; /* buffer for writing own MAC address */
488 };
489
490
491 /**
492 * struct wpa_driver_ops - Driver interface API definition
493 *
494 * This structure defines the API that each driver interface needs to implement
495 * for core wpa_supplicant code. All driver specific functionality is captured
496 * in this wrapper.
497 */
498 struct wpa_driver_ops {
499 /** Name of the driver interface */
500 const char *name;
501 /** One line description of the driver interface */
502 const char *desc;
503
504 /**
505 * get_bssid - Get the current BSSID
506 * @priv: private driver interface data
507 * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
508 *
509 * Returns: 0 on success, -1 on failure
510 *
511 * Query kernel driver for the current BSSID and copy it to bssid.
512 * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
513 * associated.
514 */
515 int (*get_bssid)(void *priv, u8 *bssid);
516
517 /**
518 * get_ssid - Get the current SSID
519 * @priv: private driver interface data
520 * @ssid: buffer for SSID (at least 32 bytes)
521 *
522 * Returns: Length of the SSID on success, -1 on failure
523 *
524 * Query kernel driver for the current SSID and copy it to ssid.
525 * Returning zero is recommended if the STA is not associated.
526 *
527 * Note: SSID is an array of octets, i.e., it is not nul terminated and
528 * can, at least in theory, contain control characters (including nul)
529 * and as such, should be processed as binary data, not a printable
530 * string.
531 */
532 int (*get_ssid)(void *priv, u8 *ssid);
533
534 /**
535 * set_key - Configure encryption key
536 * @ifname: Interface name (for multi-SSID/VLAN support)
537 * @priv: private driver interface data
538 * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
539 * %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
540 * %WPA_ALG_NONE clears the key.
541 * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
542 * broadcast/default keys
543 * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
544 * IGTK
545 * @set_tx: configure this key as the default Tx key (only used when
546 * driver does not support separate unicast/individual key
547 * @seq: sequence number/packet number, seq_len octets, the next
548 * packet number to be used for in replay protection; configured
549 * for Rx keys (in most cases, this is only used with broadcast
550 * keys and set to zero for unicast keys)
551 * @seq_len: length of the seq, depends on the algorithm:
552 * TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
553 * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
554 * 8-byte Rx Mic Key
555 * @key_len: length of the key buffer in octets (WEP: 5 or 13,
556 * TKIP: 32, CCMP: 16, IGTK: 16)
557 *
558 * Returns: 0 on success, -1 on failure
559 *
560 * Configure the given key for the kernel driver. If the driver
561 * supports separate individual keys (4 default keys + 1 individual),
562 * addr can be used to determine whether the key is default or
563 * individual. If only 4 keys are supported, the default key with key
564 * index 0 is used as the individual key. STA must be configured to use
565 * it as the default Tx key (set_tx is set) and accept Rx for all the
566 * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
567 * broadcast keys, so key index 0 is available for this kind of
568 * configuration.
569 *
570 * Please note that TKIP keys include separate TX and RX MIC keys and
571 * some drivers may expect them in different order than wpa_supplicant
572 * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
573 * will tricker Michael MIC errors. This can be fixed by changing the
574 * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
575 * in driver_*.c set_key() implementation, see driver_ndis.c for an
576 * example on how this can be done.
577 */
578 int (*set_key)(const char *ifname, void *priv, wpa_alg alg,
579 const u8 *addr, int key_idx, int set_tx,
580 const u8 *seq, size_t seq_len,
581 const u8 *key, size_t key_len);
582
583 /**
584 * init - Initialize driver interface
585 * @ctx: context to be used when calling wpa_supplicant functions,
586 * e.g., wpa_supplicant_event()
587 * @ifname: interface name, e.g., wlan0
588 *
589 * Returns: Pointer to private data, %NULL on failure
590 *
591 * Initialize driver interface, including event processing for kernel
592 * driver events (e.g., associated, scan results, Michael MIC failure).
593 * This function can allocate a private configuration data area for
594 * @ctx, file descriptor, interface name, etc. information that may be
595 * needed in future driver operations. If this is not used, non-NULL
596 * value will need to be returned because %NULL is used to indicate
597 * failure. The returned value will be used as 'void *priv' data for
598 * all other driver_ops functions.
599 *
600 * The main event loop (eloop.c) of wpa_supplicant can be used to
601 * register callback for read sockets (eloop_register_read_sock()).
602 *
603 * See below for more information about events and
604 * wpa_supplicant_event() function.
605 */
606 void * (*init)(void *ctx, const char *ifname);
607
608 /**
609 * deinit - Deinitialize driver interface
610 * @priv: private driver interface data from init()
611 *
612 * Shut down driver interface and processing of driver events. Free
613 * private data buffer if one was allocated in init() handler.
614 */
615 void (*deinit)(void *priv);
616
617 /**
618 * set_param - Set driver configuration parameters
619 * @priv: private driver interface data from init()
620 * @param: driver specific configuration parameters
621 *
622 * Returns: 0 on success, -1 on failure
623 *
624 * Optional handler for notifying driver interface about configuration
625 * parameters (driver_param).
626 */
627 int (*set_param)(void *priv, const char *param);
628
629 /**
630 * set_countermeasures - Enable/disable TKIP countermeasures
631 * @priv: private driver interface data
632 * @enabled: 1 = countermeasures enabled, 0 = disabled
633 *
634 * Returns: 0 on success, -1 on failure
635 *
636 * Configure TKIP countermeasures. When these are enabled, the driver
637 * should drop all received and queued frames that are using TKIP.
638 */
639 int (*set_countermeasures)(void *priv, int enabled);
640
641 /**
642 * deauthenticate - Request driver to deauthenticate
643 * @priv: private driver interface data
644 * @addr: peer address (BSSID of the AP)
645 * @reason_code: 16-bit reason code to be sent in the deauthentication
646 * frame
647 *
648 * Returns: 0 on success, -1 on failure
649 */
650 int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
651
652 /**
653 * disassociate - Request driver to disassociate
654 * @priv: private driver interface data
655 * @addr: peer address (BSSID of the AP)
656 * @reason_code: 16-bit reason code to be sent in the disassociation
657 * frame
658 *
659 * Returns: 0 on success, -1 on failure
660 */
661 int (*disassociate)(void *priv, const u8 *addr, int reason_code);
662
663 /**
664 * associate - Request driver to associate
665 * @priv: private driver interface data
666 * @params: association parameters
667 *
668 * Returns: 0 on success, -1 on failure
669 */
670 int (*associate)(void *priv,
671 struct wpa_driver_associate_params *params);
672
673 /**
674 * add_pmkid - Add PMKSA cache entry to the driver
675 * @priv: private driver interface data
676 * @bssid: BSSID for the PMKSA cache entry
677 * @pmkid: PMKID for the PMKSA cache entry
678 *
679 * Returns: 0 on success, -1 on failure
680 *
681 * This function is called when a new PMK is received, as a result of
682 * either normal authentication or RSN pre-authentication.
683 *
684 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
685 * associate(), add_pmkid() can be used to add new PMKSA cache entries
686 * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
687 * driver_ops function does not need to be implemented. Likewise, if
688 * the driver does not support WPA, this function is not needed.
689 */
690 int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
691
692 /**
693 * remove_pmkid - Remove PMKSA cache entry to the driver
694 * @priv: private driver interface data
695 * @bssid: BSSID for the PMKSA cache entry
696 * @pmkid: PMKID for the PMKSA cache entry
697 *
698 * Returns: 0 on success, -1 on failure
699 *
700 * This function is called when the supplicant drops a PMKSA cache
701 * entry for any reason.
702 *
703 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
704 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
705 * between the driver and wpa_supplicant. If the driver uses wpa_ie
706 * from wpa_supplicant, this driver_ops function does not need to be
707 * implemented. Likewise, if the driver does not support WPA, this
708 * function is not needed.
709 */
710 int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
711
712 /**
713 * flush_pmkid - Flush PMKSA cache
714 * @priv: private driver interface data
715 *
716 * Returns: 0 on success, -1 on failure
717 *
718 * This function is called when the supplicant drops all PMKSA cache
719 * entries for any reason.
720 *
721 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
722 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
723 * between the driver and wpa_supplicant. If the driver uses wpa_ie
724 * from wpa_supplicant, this driver_ops function does not need to be
725 * implemented. Likewise, if the driver does not support WPA, this
726 * function is not needed.
727 */
728 int (*flush_pmkid)(void *priv);
729
730 /**
731 * get_capa - Get driver capabilities
732 * @priv: private driver interface data
733 *
734 * Returns: 0 on success, -1 on failure
735 *
736 * Get driver/firmware/hardware capabilities.
737 */
738 int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
739
740 /**
741 * poll - Poll driver for association information
742 * @priv: private driver interface data
743 *
744 * This is an option callback that can be used when the driver does not
745 * provide event mechanism for association events. This is called when
746 * receiving WPA EAPOL-Key messages that require association
747 * information. The driver interface is supposed to generate associnfo
748 * event before returning from this callback function. In addition, the
749 * driver interface should generate an association event after having
750 * sent out associnfo.
751 */
752 void (*poll)(void *priv);
753
754 /**
755 * get_ifname - Get interface name
756 * @priv: private driver interface data
757 *
758 * Returns: Pointer to the interface name. This can differ from the
759 * interface name used in init() call. Init() is called first.
760 *
761 * This optional function can be used to allow the driver interface to
762 * replace the interface name with something else, e.g., based on an
763 * interface mapping from a more descriptive name.
764 */
765 const char * (*get_ifname)(void *priv);
766
767 /**
768 * get_mac_addr - Get own MAC address
769 * @priv: private driver interface data
770 *
771 * Returns: Pointer to own MAC address or %NULL on failure
772 *
773 * This optional function can be used to get the own MAC address of the
774 * device from the driver interface code. This is only needed if the
775 * l2_packet implementation for the OS does not provide easy access to
776 * a MAC address. */
777 const u8 * (*get_mac_addr)(void *priv);
778
779 /**
780 * send_eapol - Optional function for sending EAPOL packets
781 * @priv: private driver interface data
782 * @dest: Destination MAC address
783 * @proto: Ethertype
784 * @data: EAPOL packet starting with IEEE 802.1X header
785 * @data_len: Size of the EAPOL packet
786 *
787 * Returns: 0 on success, -1 on failure
788 *
789 * This optional function can be used to override l2_packet operations
790 * with driver specific functionality. If this function pointer is set,
791 * l2_packet module is not used at all and the driver interface code is
792 * responsible for receiving and sending all EAPOL packets. The
793 * received EAPOL packets are sent to core code by calling
794 * wpa_supplicant_rx_eapol(). The driver interface is required to
795 * implement get_mac_addr() handler if send_eapol() is used.
796 */
797 int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
798 const u8 *data, size_t data_len);
799
800 /**
801 * set_operstate - Sets device operating state to DORMANT or UP
802 * @priv: private driver interface data
803 * @state: 0 = dormant, 1 = up
804 * Returns: 0 on success, -1 on failure
805 *
806 * This is an optional function that can be used on operating systems
807 * that support a concept of controlling network device state from user
808 * space applications. This function, if set, gets called with
809 * state = 1 when authentication has been completed and with state = 0
810 * when connection is lost.
811 */
812 int (*set_operstate)(void *priv, int state);
813
814 /**
815 * mlme_setprotection - MLME-SETPROTECTION.request primitive
816 * @priv: Private driver interface data
817 * @addr: Address of the station for which to set protection (may be
818 * %NULL for group keys)
819 * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
820 * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
821 * Returns: 0 on success, -1 on failure
822 *
823 * This is an optional function that can be used to set the driver to
824 * require protection for Tx and/or Rx frames. This uses the layer
825 * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
826 * (MLME-SETPROTECTION.request). Many drivers do not use explicit
827 * set protection operation; instead, they set protection implicitly
828 * based on configured keys.
829 */
830 int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
831 int key_type);
832
833 /**
834 * get_hw_feature_data - Get hardware support data (channels and rates)
835 * @priv: Private driver interface data
836 * @num_modes: Variable for returning the number of returned modes
837 * flags: Variable for returning hardware feature flags
838 * Returns: Pointer to allocated hardware data on success or %NULL on
839 * failure. Caller is responsible for freeing this.
840 *
841 * This function is only needed for drivers that export MLME
842 * (management frame processing) to wpa_supplicant.
843 */
844 struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
845 u16 *num_modes,
846 u16 *flags);
847
848 /**
849 * set_channel - Set channel
850 * @priv: Private driver interface data
851 * @phymode: HOSTAPD_MODE_IEEE80211B, ..
852 * @chan: IEEE 802.11 channel number
853 * @freq: Frequency of the channel in MHz
854 * Returns: 0 on success, -1 on failure
855 *
856 * This function is only needed for drivers that export MLME
857 * (management frame processing) to wpa_supplicant.
858 */
859 int (*set_channel)(void *priv, hostapd_hw_mode phymode, int chan,
860 int freq);
861
862 /**
863 * set_ssid - Set SSID
864 * @priv: Private driver interface data
865 * @ssid: SSID
866 * @ssid_len: SSID length
867 * Returns: 0 on success, -1 on failure
868 *
869 * This function is only needed for drivers that export MLME
870 * (management frame processing) to wpa_supplicant.
871 */
872 int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
873
874 /**
875 * set_bssid - Set BSSID
876 * @priv: Private driver interface data
877 * @bssid: BSSID
878 * Returns: 0 on success, -1 on failure
879 *
880 * This function is only needed for drivers that export MLME
881 * (management frame processing) to wpa_supplicant.
882 */
883 int (*set_bssid)(void *priv, const u8 *bssid);
884
885 /**
886 * send_mlme - Send management frame from MLME
887 * @priv: Private driver interface data
888 * @data: IEEE 802.11 management frame with IEEE 802.11 header
889 * @data_len: Size of the management frame
890 * Returns: 0 on success, -1 on failure
891 *
892 * This function is only needed for drivers that export MLME
893 * (management frame processing) to wpa_supplicant.
894 */
895 int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
896
897 /**
898 * mlme_add_sta - Add a STA entry into the driver/netstack
899 * @priv: Private driver interface data
900 * @addr: MAC address of the STA (e.g., BSSID of the AP)
901 * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
902 * format (one octet per rate, 1 = 0.5 Mbps)
903 * @supp_rates_len: Number of entries in supp_rates
904 * Returns: 0 on success, -1 on failure
905 *
906 * This function is only needed for drivers that export MLME
907 * (management frame processing) to wpa_supplicant. When the MLME code
908 * completes association with an AP, this function is called to
909 * configure the driver/netstack with a STA entry for data frame
910 * processing (TX rate control, encryption/decryption).
911 */
912 int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
913 size_t supp_rates_len);
914
915 /**
916 * mlme_remove_sta - Remove a STA entry from the driver/netstack
917 * @priv: Private driver interface data
918 * @addr: MAC address of the STA (e.g., BSSID of the AP)
919 * Returns: 0 on success, -1 on failure
920 *
921 * This function is only needed for drivers that export MLME
922 * (management frame processing) to wpa_supplicant.
923 */
924 int (*mlme_remove_sta)(void *priv, const u8 *addr);
925
926 /**
927 * update_ft_ies - Update FT (IEEE 802.11r) IEs
928 * @priv: Private driver interface data
929 * @md: Mobility domain (2 octets) (also included inside ies)
930 * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
931 * @ies_len: Length of FT IEs in bytes
932 * Returns: 0 on success, -1 on failure
933 *
934 * The supplicant uses this callback to let the driver know that keying
935 * material for FT is available and that the driver can use the
936 * provided IEs in the next message in FT authentication sequence.
937 *
938 * This function is only needed for driver that support IEEE 802.11r
939 * (Fast BSS Transition).
940 */
941 int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
942 size_t ies_len);
943
944 /**
945 * send_ft_action - Send FT Action frame (IEEE 802.11r)
946 * @priv: Private driver interface data
947 * @action: Action field value
948 * @target_ap: Target AP address
949 * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
950 * @ies_len: Length of FT IEs in bytes
951 * Returns: 0 on success, -1 on failure
952 *
953 * The supplicant uses this callback to request the driver to transmit
954 * an FT Action frame (action category 6) for over-the-DS fast BSS
955 * transition.
956 */
957 int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
958 const u8 *ies, size_t ies_len);
959
960 /**
961 * get_scan_results2 - Fetch the latest scan results
962 * @priv: private driver interface data
963 *
964 * Returns: Allocated buffer of scan results (caller is responsible for
965 * freeing the data structure) on success, NULL on failure
966 */
967 struct wpa_scan_results * (*get_scan_results2)(void *priv);
968
969 /**
970 * set_country - Set country
971 * @priv: Private driver interface data
972 * @alpha2: country to which to switch to
973 * Returns: 0 on success, -1 on failure
974 *
975 * This function is for drivers which support some form
976 * of setting a regulatory domain.
977 */
978 int (*set_country)(void *priv, const char *alpha2);
979
980 /**
981 * global_init - Global driver initialization
982 * Returns: Pointer to private data (global), %NULL on failure
983 *
984 * This optional function is called to initialize the driver wrapper
985 * for global data, i.e., data that applies to all interfaces. If this
986 * function is implemented, global_deinit() will also need to be
987 * implemented to free the private data. The driver will also likely
988 * use init2() function instead of init() to get the pointer to global
989 * data available to per-interface initializer.
990 */
991 void * (*global_init)(void);
992
993 /**
994 * global_deinit - Global driver deinitialization
995 * @priv: private driver global data from global_init()
996 *
997 * Terminate any global driver related functionality and free the
998 * global data structure.
999 */
1000 void (*global_deinit)(void *priv);
1001
1002 /**
1003 * init2 - Initialize driver interface (with global data)
1004 * @ctx: context to be used when calling wpa_supplicant functions,
1005 * e.g., wpa_supplicant_event()
1006 * @ifname: interface name, e.g., wlan0
1007 * @global_priv: private driver global data from global_init()
1008 * Returns: Pointer to private data, %NULL on failure
1009 *
1010 * This function can be used instead of init() if the driver wrapper
1011 * uses global data.
1012 */
1013 void * (*init2)(void *ctx, const char *ifname, void *global_priv);
1014
1015 /**
1016 * get_interfaces - Get information about available interfaces
1017 * @global_priv: private driver global data from global_init()
1018 * Returns: Allocated buffer of interface information (caller is
1019 * responsible for freeing the data structure) on success, NULL on
1020 * failure
1021 */
1022 struct wpa_interface_info * (*get_interfaces)(void *global_priv);
1023
1024 /**
1025 * scan2 - Request the driver to initiate scan
1026 * @priv: private driver interface data
1027 * @params: Scan parameters
1028 *
1029 * Returns: 0 on success, -1 on failure
1030 *
1031 * Once the scan results are ready, the driver should report scan
1032 * results event for wpa_supplicant which will eventually request the
1033 * results with wpa_driver_get_scan_results2().
1034 */
1035 int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
1036
1037 /**
1038 * authenticate - Request driver to authenticate
1039 * @priv: private driver interface data
1040 * @params: authentication parameters
1041 * Returns: 0 on success, -1 on failure
1042 *
1043 * This is an optional function that can be used with drivers that
1044 * support separate authentication and association steps, i.e., when
1045 * wpa_supplicant can act as the SME. If not implemented, associate()
1046 * function is expected to take care of IEEE 802.11 authentication,
1047 * too.
1048 */
1049 int (*authenticate)(void *priv,
1050 struct wpa_driver_auth_params *params);
1051
1052 int (*set_beacon)(const char *ifname, void *priv,
1053 const u8 *head, size_t head_len,
1054 const u8 *tail, size_t tail_len, int dtim_period,
1055 int beacon_int);
1056
1057 void * (*hapd_init)(struct hostapd_data *hapd,
1058 struct wpa_init_params *params);
1059 void (*hapd_deinit)(void *priv);
1060
1061 /**
1062 * set_8021x - enable/disable IEEE 802.1X support
1063 * @ifname: Interface name (for multi-SSID/VLAN support)
1064 * @priv: driver private data
1065 * @enabled: 1 = enable, 0 = disable
1066 *
1067 * Returns: 0 on success, -1 on failure
1068 *
1069 * Configure the kernel driver to enable/disable 802.1X support.
1070 * This may be an empty function if 802.1X support is always enabled.
1071 */
1072 int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
1073
1074 /**
1075 * set_privacy - enable/disable privacy
1076 * @priv: driver private data
1077 * @enabled: 1 = privacy enabled, 0 = disabled
1078 *
1079 * Return: 0 on success, -1 on failure
1080 *
1081 * Configure privacy.
1082 */
1083 int (*set_privacy)(const char *ifname, void *priv, int enabled);
1084
1085 int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
1086 int idx, u8 *seq);
1087 int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
1088 int idx, u8 *seq);
1089 int (*flush)(void *priv);
1090 int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
1091 size_t elem_len);
1092
1093 int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
1094 const u8 *addr);
1095 int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
1096 size_t data_len, int encrypt,
1097 const u8 *own_addr);
1098 int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
1099 int reason);
1100 int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
1101 int reason);
1102 int (*sta_remove)(void *priv, const u8 *addr);
1103 int (*hapd_get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
1104 int (*hapd_set_ssid)(const char *ifname, void *priv, const u8 *buf,
1105 int len);
1106 int (*hapd_set_countermeasures)(void *priv, int enabled);
1107 int (*sta_add)(const char *ifname, void *priv,
1108 struct hostapd_sta_add_params *params);
1109 int (*get_inact_sec)(void *priv, const u8 *addr);
1110 int (*sta_clear_stats)(void *priv, const u8 *addr);
1111
1112 int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
1113 int (*set_rts)(void *priv, int rts);
1114 int (*set_frag)(void *priv, int frag);
1115
1116 int (*sta_set_flags)(void *priv, const u8 *addr,
1117 int total_flags, int flags_or, int flags_and);
1118 int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
1119 int mode);
1120
1121 /* Configure internal bridge:
1122 * 0 = disabled, i.e., client separation is enabled (no bridging of
1123 * packets between associated STAs
1124 * 1 = enabled, i.e., bridge packets between associated STAs (default)
1125 */
1126 int (*set_internal_bridge)(void *priv, int value);
1127 int (*set_cts_protect)(void *priv, int value);
1128 int (*set_preamble)(void *priv, int value);
1129 int (*set_short_slot_time)(void *priv, int value);
1130 int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
1131 int cw_max, int burst_time);
1132 int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
1133
1134 /**
1135 * if_add - Add a virtual interface
1136 * @priv: Private driver interface data
1137 * @iface: Parent interface name
1138 * @type: Interface type
1139 * @ifname: Interface name for the new virtual interface
1140 * @addr: Local address to use for the interface or %NULL to use the
1141 * parent interface address
1142 * Returns: 0 on success, -1 on failure
1143 */
1144 int (*if_add)(const char *iface, void *priv,
1145 enum wpa_driver_if_type type, const char *ifname,
1146 const u8 *addr);
1147
1148 /**
1149 * if_remove - Remove a virtual interface
1150 * @priv: Private driver interface data
1151 * @type: Interface type
1152 * @ifname: Interface name of the virtual interface to be removed
1153 * Returns: 0 on success, -1 on failure
1154 */
1155 int (*if_remove)(void *priv, enum wpa_driver_if_type type,
1156 const char *ifname);
1157 int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
1158 int vlan_id);
1159 /**
1160 * commit - Optional commit changes handler
1161 * @priv: driver private data
1162 * Returns: 0 on success, -1 on failure
1163 *
1164 * This optional handler function can be registered if the driver
1165 * interface implementation needs to commit changes (e.g., by setting
1166 * network interface up) at the end of initial configuration. If set,
1167 * this handler will be called after initial setup has been completed.
1168 */
1169 int (*commit)(void *priv);
1170
1171 int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
1172 const u8 *data, size_t data_len);
1173
1174 int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
1175 u32 session_timeout);
1176 int (*set_radius_acl_expire)(void *priv, const u8 *mac);
1177
1178 int (*set_ht_params)(const char *ifname, void *priv,
1179 const u8 *ht_capab, size_t ht_capab_len,
1180 const u8 *ht_oper, size_t ht_oper_len);
1181
1182 int (*set_wps_beacon_ie)(const char *ifname, void *priv,
1183 const u8 *ie, size_t len);
1184 int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
1185 const u8 *ie, size_t len);
1186
1187 /**
1188 * set_supp_port - Set IEEE 802.1X Supplicant Port status
1189 * @priv: Private driver interface data
1190 * @authorized: Whether the port is authorized
1191 * Returns: 0 on success, -1 on failure
1192 */
1193 int (*set_supp_port)(void *priv, int authorized);
1194 };
1195
1196 /**
1197 * enum wpa_event_type - Event type for wpa_supplicant_event() calls
1198 */
1199 typedef enum wpa_event_type {
1200 /**
1201 * EVENT_ASSOC - Association completed
1202 *
1203 * This event needs to be delivered when the driver completes IEEE
1204 * 802.11 association or reassociation successfully.
1205 * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
1206 * after this event has been generated. In addition, optional
1207 * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
1208 * more information about the association. If the driver interface gets
1209 * both of these events at the same time, it can also include the
1210 * assoc_info data in EVENT_ASSOC call.
1211 */
1212 EVENT_ASSOC,
1213
1214 /**
1215 * EVENT_DISASSOC - Association lost
1216 *
1217 * This event should be called when association is lost either due to
1218 * receiving deauthenticate or disassociate frame from the AP or when
1219 * sending either of these frames to the current AP. If the driver
1220 * supports separate deauthentication event, EVENT_DISASSOC should only
1221 * be used for disassociation and EVENT_DEAUTH for deauthentication.
1222 */
1223 EVENT_DISASSOC,
1224
1225 /**
1226 * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
1227 *
1228 * This event must be delivered when a Michael MIC error is detected by
1229 * the local driver. Additional data for event processing is
1230 * provided with union wpa_event_data::michael_mic_failure. This
1231 * information is used to request new encyption key and to initiate
1232 * TKIP countermeasures if needed.
1233 */
1234 EVENT_MICHAEL_MIC_FAILURE,
1235
1236 /**
1237 * EVENT_SCAN_RESULTS - Scan results available
1238 *
1239 * This event must be called whenever scan results are available to be
1240 * fetched with struct wpa_driver_ops::get_scan_results(). This event
1241 * is expected to be used some time after struct wpa_driver_ops::scan()
1242 * is called. If the driver provides an unsolicited event when the scan
1243 * has been completed, this event can be used to trigger
1244 * EVENT_SCAN_RESULTS call. If such event is not available from the
1245 * driver, the driver wrapper code is expected to use a registered
1246 * timeout to generate EVENT_SCAN_RESULTS call after the time that the
1247 * scan is expected to be completed.
1248 */
1249 EVENT_SCAN_RESULTS,
1250
1251 /**
1252 * EVENT_ASSOCINFO - Report optional extra information for association
1253 *
1254 * This event can be used to report extra association information for
1255 * EVENT_ASSOC processing. This extra information includes IEs from
1256 * association frames and Beacon/Probe Response frames in union
1257 * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
1258 * EVENT_ASSOC. Alternatively, the driver interface can include
1259 * assoc_info data in the EVENT_ASSOC call if it has all the
1260 * information available at the same point.
1261 */
1262 EVENT_ASSOCINFO,
1263
1264 /**
1265 * EVENT_INTERFACE_STATUS - Report interface status changes
1266 *
1267 * This optional event can be used to report changes in interface
1268 * status (interface added/removed) using union
1269 * wpa_event_data::interface_status. This can be used to trigger
1270 * wpa_supplicant to stop and re-start processing for the interface,
1271 * e.g., when a cardbus card is ejected/inserted.
1272 */
1273 EVENT_INTERFACE_STATUS,
1274
1275 /**
1276 * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
1277 *
1278 * This event can be used to inform wpa_supplicant about candidates for
1279 * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
1280 * for scan request (ap_scan=2 mode), this event is required for
1281 * pre-authentication. If wpa_supplicant is performing scan request
1282 * (ap_scan=1), this event is optional since scan results can be used
1283 * to add pre-authentication candidates. union
1284 * wpa_event_data::pmkid_candidate is used to report the BSSID of the
1285 * candidate and priority of the candidate, e.g., based on the signal
1286 * strength, in order to try to pre-authenticate first with candidates
1287 * that are most likely targets for re-association.
1288 *
1289 * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
1290 * on the candidate list. In addition, it can be called for the current
1291 * AP and APs that have existing PMKSA cache entries. wpa_supplicant
1292 * will automatically skip pre-authentication in cases where a valid
1293 * PMKSA exists. When more than one candidate exists, this event should
1294 * be generated once for each candidate.
1295 *
1296 * Driver will be notified about successful pre-authentication with
1297 * struct wpa_driver_ops::add_pmkid() calls.
1298 */
1299 EVENT_PMKID_CANDIDATE,
1300
1301 /**
1302 * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
1303 *
1304 * This event can be used to inform wpa_supplicant about desire to set
1305 * up secure direct link connection between two stations as defined in
1306 * IEEE 802.11e with a new PeerKey mechanism that replaced the original
1307 * STAKey negotiation. The caller will need to set peer address for the
1308 * event.
1309 */
1310 EVENT_STKSTART,
1311
1312 /**
1313 * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
1314 *
1315 * The driver is expected to report the received FT IEs from
1316 * FT authentication sequence from the AP. The FT IEs are included in
1317 * the extra information in union wpa_event_data::ft_ies.
1318 */
1319 EVENT_FT_RESPONSE,
1320
1321 /**
1322 * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
1323 *
1324 * The driver can use this event to inform wpa_supplicant about a STA
1325 * in an IBSS with which protected frames could be exchanged. This
1326 * event starts RSN authentication with the other STA to authenticate
1327 * the STA and set up encryption keys with it.
1328 */
1329 EVENT_IBSS_RSN_START,
1330
1331 /**
1332 * EVENT_AUTH - Authentication result
1333 *
1334 * This event should be called when authentication attempt has been
1335 * completed. This is only used if the driver supports separate
1336 * authentication step (struct wpa_driver_ops::authenticate).
1337 * Information about authentication result is included in
1338 * union wpa_event_data::auth.
1339 */
1340 EVENT_AUTH,
1341
1342 /**
1343 * EVENT_DEAUTH - Authentication lost
1344 *
1345 * This event should be called when authentication is lost either due
1346 * to receiving deauthenticate frame from the AP or when sending that
1347 * frame to the current AP.
1348 */
1349 EVENT_DEAUTH,
1350
1351 /**
1352 * EVENT_ASSOC_REJECT - Association rejected
1353 *
1354 * This event should be called when (re)association attempt has been
1355 * rejected by the AP. Information about authentication result is
1356 * included in union wpa_event_data::assoc_reject.
1357 */
1358 EVENT_ASSOC_REJECT,
1359
1360 /**
1361 * EVENT_AUTH_TIMED_OUT - Authentication timed out
1362 */
1363 EVENT_AUTH_TIMED_OUT,
1364
1365 /**
1366 * EVENT_ASSOC_TIMED_OUT - Association timed out
1367 */
1368 EVENT_ASSOC_TIMED_OUT
1369 } wpa_event_type;
1370
1371
1372 /**
1373 * union wpa_event_data - Additional data for wpa_supplicant_event() calls
1374 */
1375 union wpa_event_data {
1376 /**
1377 * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
1378 *
1379 * This structure is optional for EVENT_ASSOC calls and required for
1380 * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
1381 * driver interface does not need to generate separate EVENT_ASSOCINFO
1382 * calls.
1383 */
1384 struct assoc_info {
1385 /**
1386 * req_ies - (Re)Association Request IEs
1387 *
1388 * If the driver generates WPA/RSN IE, this event data must be
1389 * returned for WPA handshake to have needed information. If
1390 * wpa_supplicant-generated WPA/RSN IE is used, this
1391 * information event is optional.
1392 *
1393 * This should start with the first IE (fixed fields before IEs
1394 * are not included).
1395 */
1396 u8 *req_ies;
1397
1398 /**
1399 * req_ies_len - Length of req_ies in bytes
1400 */
1401 size_t req_ies_len;
1402
1403 /**
1404 * resp_ies - (Re)Association Response IEs
1405 *
1406 * Optional association data from the driver. This data is not
1407 * required WPA, but may be useful for some protocols and as
1408 * such, should be reported if this is available to the driver
1409 * interface.
1410 *
1411 * This should start with the first IE (fixed fields before IEs
1412 * are not included).
1413 */
1414 u8 *resp_ies;
1415
1416 /**
1417 * resp_ies_len - Length of resp_ies in bytes
1418 */
1419 size_t resp_ies_len;
1420
1421 /**
1422 * beacon_ies - Beacon or Probe Response IEs
1423 *
1424 * Optional Beacon/ProbeResp data: IEs included in Beacon or
1425 * Probe Response frames from the current AP (i.e., the one
1426 * that the client just associated with). This information is
1427 * used to update WPA/RSN IE for the AP. If this field is not
1428 * set, the results from previous scan will be used. If no
1429 * data for the new AP is found, scan results will be requested
1430 * again (without scan request). At this point, the driver is
1431 * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
1432 * used).
1433 *
1434 * This should start with the first IE (fixed fields before IEs
1435 * are not included).
1436 */
1437 u8 *beacon_ies;
1438
1439 /**
1440 * beacon_ies_len - Length of beacon_ies */
1441 size_t beacon_ies_len;
1442 } assoc_info;
1443
1444 /**
1445 * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
1446 */
1447 struct michael_mic_failure {
1448 int unicast;
1449 const u8 *src;
1450 } michael_mic_failure;
1451
1452 /**
1453 * struct interface_status - Data for EVENT_INTERFACE_STATUS
1454 */
1455 struct interface_status {
1456 char ifname[100];
1457 enum {
1458 EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
1459 } ievent;
1460 } interface_status;
1461
1462 /**
1463 * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
1464 */
1465 struct pmkid_candidate {
1466 /** BSSID of the PMKID candidate */
1467 u8 bssid[ETH_ALEN];
1468 /** Smaller the index, higher the priority */
1469 int index;
1470 /** Whether RSN IE includes pre-authenticate flag */
1471 int preauth;
1472 } pmkid_candidate;
1473
1474 /**
1475 * struct stkstart - Data for EVENT_STKSTART
1476 */
1477 struct stkstart {
1478 u8 peer[ETH_ALEN];
1479 } stkstart;
1480
1481 /**
1482 * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
1483 *
1484 * During FT (IEEE 802.11r) authentication sequence, the driver is
1485 * expected to use this event to report received FT IEs (MDIE, FTIE,
1486 * RSN IE, TIE, possible resource request) to the supplicant. The FT
1487 * IEs for the next message will be delivered through the
1488 * struct wpa_driver_ops::update_ft_ies() callback.
1489 */
1490 struct ft_ies {
1491 const u8 *ies;
1492 size_t ies_len;
1493 int ft_action;
1494 u8 target_ap[ETH_ALEN];
1495 /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
1496 const u8 *ric_ies;
1497 /** Length of ric_ies buffer in octets */
1498 size_t ric_ies_len;
1499 } ft_ies;
1500
1501 /**
1502 * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
1503 */
1504 struct ibss_rsn_start {
1505 u8 peer[ETH_ALEN];
1506 } ibss_rsn_start;
1507
1508 /**
1509 * struct auth_info - Data for EVENT_AUTH events
1510 */
1511 struct auth_info {
1512 u8 peer[ETH_ALEN];
1513 u16 auth_type;
1514 u16 status_code;
1515 const u8 *ies;
1516 size_t ies_len;
1517 } auth;
1518
1519 /**
1520 * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
1521 */
1522 struct assoc_reject {
1523 /**
1524 * resp_ies - (Re)Association Response IEs
1525 *
1526 * Optional association data from the driver. This data is not
1527 * required WPA, but may be useful for some protocols and as
1528 * such, should be reported if this is available to the driver
1529 * interface.
1530 *
1531 * This should start with the first IE (fixed fields before IEs
1532 * are not included).
1533 */
1534 u8 *resp_ies;
1535
1536 /**
1537 * resp_ies_len - Length of resp_ies in bytes
1538 */
1539 size_t resp_ies_len;
1540
1541 /**
1542 * status_code - Status Code from (Re)association Response
1543 */
1544 u16 status_code;
1545 } assoc_reject;
1546
1547 struct timeout_event {
1548 u8 addr[ETH_ALEN];
1549 } timeout_event;
1550 };
1551
1552 /**
1553 * wpa_supplicant_event - Report a driver event for wpa_supplicant
1554 * @ctx: Context pointer (wpa_s); this is the ctx variable registered
1555 * with struct wpa_driver_ops::init()
1556 * @event: event type (defined above)
1557 * @data: possible extra data for the event
1558 *
1559 * Driver wrapper code should call this function whenever an event is received
1560 * from the driver.
1561 */
1562 void wpa_supplicant_event(void *ctx, wpa_event_type event,
1563 union wpa_event_data *data);
1564
1565 /**
1566 * wpa_supplicant_rx_eapol - Deliver a received EAPOL frame to wpa_supplicant
1567 * @ctx: Context pointer (wpa_s); this is the ctx variable registered
1568 * with struct wpa_driver_ops::init()
1569 * @src_addr: Source address of the EAPOL frame
1570 * @buf: EAPOL data starting from the EAPOL header (i.e., no Ethernet header)
1571 * @len: Length of the EAPOL data
1572 *
1573 * This function is called for each received EAPOL frame. Most driver
1574 * interfaces rely on more generic OS mechanism for receiving frames through
1575 * l2_packet, but if such a mechanism is not available, the driver wrapper may
1576 * take care of received EAPOL frames and deliver them to the core supplicant
1577 * code by calling this function.
1578 */
1579 void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
1580 const u8 *buf, size_t len);
1581
1582 void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len,
1583 struct ieee80211_rx_status *rx_status);
1584
1585 const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie);
1586 #define WPA_IE_VENDOR_TYPE 0x0050f201
1587 #define WPS_IE_VENDOR_TYPE 0x0050f204
1588 const u8 * wpa_scan_get_vendor_ie(const struct wpa_scan_res *res,
1589 u32 vendor_type);
1590 struct wpabuf * wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res *res,
1591 u32 vendor_type);
1592 int wpa_scan_get_max_rate(const struct wpa_scan_res *res);
1593 void wpa_scan_results_free(struct wpa_scan_results *res);
1594 void wpa_scan_sort_results(struct wpa_scan_results *res);
1595
1596 /* hostapd functions for driver wrappers */
1597
1598 struct sta_info;
1599 struct ieee80211_hdr;
1600
1601 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
1602 int reassoc);
1603 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
1604 const u8 *buf, size_t len, int ack);
1605 void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd,
1606 const struct ieee80211_hdr *hdr, size_t len);
1607 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
1608 const u8 *ie, size_t ielen);
1609 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
1610 void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa,
1611 const u8 *buf, size_t len);
1612
1613 struct hostapd_frame_info {
1614 u32 channel;
1615 u32 datarate;
1616 u32 ssi_signal;
1617 };
1618
1619 void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len,
1620 u16 stype, struct hostapd_frame_info *fi);
1621 void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
1622 u16 stype, int ok);
1623 void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr);
1624 struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd,
1625 const u8 *addr);
1626 void hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
1627 const u8 *ie, size_t ie_len);
1628 void hostapd_button_pushed(struct hostapd_data *hapd);
1629
1630 #endif /* DRIVER_H */