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