2 * Driver interface definition
3 * Copyright (c) 2003-2010, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
14 * This file defines a driver interface used by both %wpa_supplicant and
15 * hostapd. The first part of the file defines data structures used in various
16 * driver operations. This is followed by the struct wpa_driver_ops that each
17 * driver wrapper will beed to define with callback functions for requesting
18 * driver operations. After this, there are definitions for driver event
19 * reporting with wpa_supplicant_event() and some convenience helper functions
20 * that can be used to report events.
26 #define WPA_SUPPLICANT_DRIVER_VERSION 4
28 #include "common/defs.h"
30 #define HOSTAPD_CHAN_DISABLED 0x00000001
31 #define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
32 #define HOSTAPD_CHAN_NO_IBSS 0x00000004
33 #define HOSTAPD_CHAN_RADAR 0x00000008
36 * struct hostapd_channel_data - Channel information
38 struct hostapd_channel_data
{
40 * chan - Channel number (IEEE 802.11)
45 * freq - Frequency in MHz
50 * flag - Channel flags (HOSTAPD_CHAN_*)
55 * max_tx_power - maximum transmit power in dBm
61 * struct hostapd_hw_modes - Supported hardware mode information
63 struct hostapd_hw_modes
{
65 * mode - Hardware mode
67 enum hostapd_hw_mode mode
;
70 * num_channels - Number of entries in the channels array
75 * channels - Array of supported channels
77 struct hostapd_channel_data
*channels
;
80 * num_rates - Number of entries in the rates array
85 * rates - Array of supported rates in 100 kbps units
90 * ht_capab - HT (IEEE 802.11n) capabilities
95 * mcs_set - MCS (IEEE 802.11n) rate parameters
100 * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
106 #define AUTH_ALG_OPEN_SYSTEM 0x01
107 #define AUTH_ALG_SHARED_KEY 0x02
108 #define AUTH_ALG_LEAP 0x04
109 #define AUTH_ALG_FT 0x08
111 #define IEEE80211_MODE_INFRA 0
112 #define IEEE80211_MODE_IBSS 1
113 #define IEEE80211_MODE_AP 2
115 #define IEEE80211_CAP_ESS 0x0001
116 #define IEEE80211_CAP_IBSS 0x0002
117 #define IEEE80211_CAP_PRIVACY 0x0010
119 #define WPA_SCAN_QUAL_INVALID BIT(0)
120 #define WPA_SCAN_NOISE_INVALID BIT(1)
121 #define WPA_SCAN_LEVEL_INVALID BIT(2)
122 #define WPA_SCAN_LEVEL_DBM BIT(3)
123 #define WPA_SCAN_AUTHENTICATED BIT(4)
124 #define WPA_SCAN_ASSOCIATED BIT(5)
127 * struct wpa_scan_res - Scan result for an BSS/IBSS
128 * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
130 * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
131 * @beacon_int: beacon interval in TUs (host byte order)
132 * @caps: capability information field in host byte order
133 * @qual: signal quality
134 * @noise: noise level
135 * @level: signal level
137 * @age: Age of the information in milliseconds (i.e., how many milliseconds
138 * ago the last Beacon or Probe Response frame was received)
139 * @ie_len: length of the following IE field in octets
141 * This structure is used as a generic format for scan results from the
142 * driver. Each driver interface implementation is responsible for converting
143 * the driver or OS specific scan results into this format.
145 * If the driver does not support reporting all IEs, the IE data structure is
146 * constructed of the IEs that are available. This field will also need to
147 * include SSID in IE format. All drivers are encouraged to be extended to
148 * report all IEs to make it easier to support future additions.
150 struct wpa_scan_res
{
162 /* followed by ie_len octets of IEs */
166 * struct wpa_scan_results - Scan results
167 * @res: Array of pointers to allocated variable length scan result entries
168 * @num: Number of entries in the scan result array
170 struct wpa_scan_results
{
171 struct wpa_scan_res
**res
;
176 * struct wpa_interface_info - Network interface information
177 * @next: Pointer to the next interface or NULL if this is the last one
178 * @ifname: Interface name that can be used with init() or init2()
179 * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
181 * @drv_name: struct wpa_driver_ops::name (note: unlike other strings, this one
182 * is not an allocated copy, i.e., get_interfaces() caller will not free
185 struct wpa_interface_info
{
186 struct wpa_interface_info
*next
;
189 const char *drv_name
;
192 #define WPAS_MAX_SCAN_SSIDS 4
195 * struct wpa_driver_scan_params - Scan parameters
196 * Data for struct wpa_driver_ops::scan2().
198 struct wpa_driver_scan_params
{
200 * ssids - SSIDs to scan for
202 struct wpa_driver_scan_ssid
{
204 * ssid - specific SSID to scan for (ProbeReq)
205 * %NULL or zero-length SSID is used to indicate active scan
206 * with wildcard SSID.
210 * ssid_len: Length of the SSID in octets
213 } ssids
[WPAS_MAX_SCAN_SSIDS
];
216 * num_ssids - Number of entries in ssids array
217 * Zero indicates a request for a passive scan.
222 * extra_ies - Extra IE(s) to add into Probe Request or %NULL
227 * extra_ies_len - Length of extra_ies in octets
229 size_t extra_ies_len
;
232 * freqs - Array of frequencies to scan or %NULL for all frequencies
234 * The frequency is set in MHz. The array is zero-terminated.
240 * struct wpa_driver_auth_params - Authentication parameters
241 * Data for struct wpa_driver_ops::authenticate().
243 struct wpa_driver_auth_params
{
251 const u8
*wep_key
[4];
252 size_t wep_key_len
[4];
257 * struct wpa_driver_associate_params - Association parameters
258 * Data for struct wpa_driver_ops::associate().
260 struct wpa_driver_associate_params
{
262 * bssid - BSSID of the selected AP
263 * This can be %NULL, if ap_scan=2 mode is used and the driver is
264 * responsible for selecting with which BSS to associate. */
268 * ssid - The selected SSID
273 * ssid_len - Length of the SSID (1..32)
278 * freq - Frequency of the channel the selected AP is using
279 * Frequency that the selected AP is using (in MHz as
280 * reported in the scan results)
285 * wpa_ie - WPA information element for (Re)Association Request
286 * WPA information element to be included in (Re)Association
287 * Request (including information element id and length). Use
288 * of this WPA IE is optional. If the driver generates the WPA
289 * IE, it can use pairwise_suite, group_suite, and
290 * key_mgmt_suite to select proper algorithms. In this case,
291 * the driver has to notify wpa_supplicant about the used WPA
292 * IE by generating an event that the interface code will
293 * convert into EVENT_ASSOCINFO data (see below).
295 * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
296 * instead. The driver can determine which version is used by
297 * looking at the first byte of the IE (0xdd for WPA, 0x30 for
300 * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
305 * wpa_ie_len - length of the wpa_ie
310 * pairwise_suite - Selected pairwise cipher suite
312 * This is usually ignored if @wpa_ie is used.
314 enum wpa_cipher pairwise_suite
;
317 * group_suite - Selected group cipher suite
319 * This is usually ignored if @wpa_ie is used.
321 enum wpa_cipher group_suite
;
324 * key_mgmt_suite - Selected key management suite
326 * This is usually ignored if @wpa_ie is used.
328 enum wpa_key_mgmt key_mgmt_suite
;
331 * auth_alg - Allowed authentication algorithms
332 * Bit field of AUTH_ALG_*
337 * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
342 * wep_key - WEP keys for static WEP configuration
344 const u8
*wep_key
[4];
347 * wep_key_len - WEP key length for static WEP configuration
349 size_t wep_key_len
[4];
352 * wep_tx_keyidx - WEP TX key index for static WEP configuration
357 * mgmt_frame_protection - IEEE 802.11w management frame protection
359 enum mfp_options mgmt_frame_protection
;
362 * ft_ies - IEEE 802.11r / FT information elements
363 * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
364 * for fast transition, this parameter is set to include the IEs that
365 * are to be sent in the next FT Authentication Request message.
366 * update_ft_ies() handler is called to update the IEs for further
367 * FT messages in the sequence.
369 * The driver should use these IEs only if the target AP is advertising
370 * the same mobility domain as the one included in the MDIE here.
372 * In ap_scan=2 mode, the driver can use these IEs when moving to a new
373 * AP after the initial association. These IEs can only be used if the
374 * target AP is advertising support for FT and is using the same MDIE
375 * and SSID as the current AP.
377 * The driver is responsible for reporting the FT IEs received from the
378 * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
379 * type. update_ft_ies() handler will then be called with the FT IEs to
380 * include in the next frame in the authentication sequence.
385 * ft_ies_len - Length of ft_ies in bytes
390 * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
392 * This value is provided to allow the driver interface easier access
393 * to the current mobility domain. This value is set to %NULL if no
394 * mobility domain is currently active.
399 * passphrase - RSN passphrase for PSK
401 * This value is made available only for WPA/WPA2-Personal (PSK) and
402 * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
403 * the 8..63 character ASCII passphrase, if available. Please note that
404 * this can be %NULL if passphrase was not used to generate the PSK. In
405 * that case, the psk field must be used to fetch the PSK.
407 const char *passphrase
;
410 * psk - RSN PSK (alternative for passphrase for PSK)
412 * This value is made available only for WPA/WPA2-Personal (PSK) and
413 * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
414 * the 32-octet (256-bit) PSK, if available. The driver wrapper should
415 * be prepared to handle %NULL value as an error.
420 * drop_unencrypted - Enable/disable unencrypted frame filtering
422 * Configure the driver to drop all non-EAPOL frames (both receive and
423 * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
424 * still be allowed for key negotiation.
426 int drop_unencrypted
;
429 * prev_bssid - Previously used BSSID in this ESS
431 * When not %NULL, this is a request to use reassociation instead of
434 const u8
*prev_bssid
;
438 * struct wpa_driver_capa - Driver capability information
440 struct wpa_driver_capa
{
441 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
442 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
443 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK 0x00000004
444 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK 0x00000008
445 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE 0x00000010
446 #define WPA_DRIVER_CAPA_KEY_MGMT_FT 0x00000020
447 #define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK 0x00000040
448 unsigned int key_mgmt
;
450 #define WPA_DRIVER_CAPA_ENC_WEP40 0x00000001
451 #define WPA_DRIVER_CAPA_ENC_WEP104 0x00000002
452 #define WPA_DRIVER_CAPA_ENC_TKIP 0x00000004
453 #define WPA_DRIVER_CAPA_ENC_CCMP 0x00000008
456 #define WPA_DRIVER_AUTH_OPEN 0x00000001
457 #define WPA_DRIVER_AUTH_SHARED 0x00000002
458 #define WPA_DRIVER_AUTH_LEAP 0x00000004
461 /* Driver generated WPA/RSN IE */
462 #define WPA_DRIVER_FLAGS_DRIVER_IE 0x00000001
463 /* Driver needs static WEP key setup after association command */
464 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
465 #define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
466 /* Driver takes care of RSN 4-way handshake internally; PMK is configured with
467 * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
468 #define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
469 #define WPA_DRIVER_FLAGS_WIRED 0x00000010
470 /* Driver provides separate commands for authentication and association (SME in
471 * wpa_supplicant). */
472 #define WPA_DRIVER_FLAGS_SME 0x00000020
473 /* Driver supports AP mode */
474 #define WPA_DRIVER_FLAGS_AP 0x00000040
475 /* Driver needs static WEP key setup after association has been completed */
476 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE 0x00000080
485 struct hostap_sta_driver_data
{
486 unsigned long rx_packets
, tx_packets
, rx_bytes
, tx_bytes
;
487 unsigned long current_tx_rate
;
488 unsigned long inactive_msec
;
490 unsigned long num_ps_buf_frames
;
491 unsigned long tx_retry_failed
;
492 unsigned long tx_retry_count
;
497 struct hostapd_sta_add_params
{
501 const u8
*supp_rates
;
502 size_t supp_rates_len
;
504 const struct ieee80211_ht_capabilities
*ht_capabilities
;
507 struct hostapd_freq_params
{
512 int sec_channel_offset
; /* 0 = HT40 disabled, -1 = HT40 enabled,
513 * secondary channel below primary, 1 = HT40
514 * enabled, secondary channel above primary */
517 enum wpa_driver_if_type
{
519 * WPA_IF_STATION - Station mode interface
524 * WPA_IF_AP_VLAN - AP mode VLAN interface
526 * This interface shares its address and Beacon frame with the main
532 * WPA_IF_AP_BSS - AP mode BSS interface
534 * This interface has its own address and Beacon frame.
539 struct wpa_init_params
{
544 const char *test_socket
;
545 int use_pae_group_addr
;
549 u8
*own_addr
; /* buffer for writing own MAC address */
553 struct wpa_bss_params
{
554 /** Interface name (for multi-SSID/VLAN support) */
556 /** Whether IEEE 802.1X or WPA/WPA2 is enabled */
567 #define WPA_STA_AUTHORIZED BIT(0)
568 #define WPA_STA_WMM BIT(1)
569 #define WPA_STA_SHORT_PREAMBLE BIT(2)
570 #define WPA_STA_MFP BIT(3)
573 * struct wpa_driver_ops - Driver interface API definition
575 * This structure defines the API that each driver interface needs to implement
576 * for core wpa_supplicant code. All driver specific functionality is captured
579 struct wpa_driver_ops
{
580 /** Name of the driver interface */
582 /** One line description of the driver interface */
586 * get_bssid - Get the current BSSID
587 * @priv: private driver interface data
588 * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
590 * Returns: 0 on success, -1 on failure
592 * Query kernel driver for the current BSSID and copy it to bssid.
593 * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
596 int (*get_bssid
)(void *priv
, u8
*bssid
);
599 * get_ssid - Get the current SSID
600 * @priv: private driver interface data
601 * @ssid: buffer for SSID (at least 32 bytes)
603 * Returns: Length of the SSID on success, -1 on failure
605 * Query kernel driver for the current SSID and copy it to ssid.
606 * Returning zero is recommended if the STA is not associated.
608 * Note: SSID is an array of octets, i.e., it is not nul terminated and
609 * can, at least in theory, contain control characters (including nul)
610 * and as such, should be processed as binary data, not a printable
613 int (*get_ssid
)(void *priv
, u8
*ssid
);
616 * set_key - Configure encryption key
617 * @ifname: Interface name (for multi-SSID/VLAN support)
618 * @priv: private driver interface data
619 * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
620 * %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
621 * %WPA_ALG_NONE clears the key.
622 * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
623 * broadcast/default keys
624 * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
626 * @set_tx: configure this key as the default Tx key (only used when
627 * driver does not support separate unicast/individual key
628 * @seq: sequence number/packet number, seq_len octets, the next
629 * packet number to be used for in replay protection; configured
630 * for Rx keys (in most cases, this is only used with broadcast
631 * keys and set to zero for unicast keys)
632 * @seq_len: length of the seq, depends on the algorithm:
633 * TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
634 * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
636 * @key_len: length of the key buffer in octets (WEP: 5 or 13,
637 * TKIP: 32, CCMP: 16, IGTK: 16)
639 * Returns: 0 on success, -1 on failure
641 * Configure the given key for the kernel driver. If the driver
642 * supports separate individual keys (4 default keys + 1 individual),
643 * addr can be used to determine whether the key is default or
644 * individual. If only 4 keys are supported, the default key with key
645 * index 0 is used as the individual key. STA must be configured to use
646 * it as the default Tx key (set_tx is set) and accept Rx for all the
647 * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
648 * broadcast keys, so key index 0 is available for this kind of
651 * Please note that TKIP keys include separate TX and RX MIC keys and
652 * some drivers may expect them in different order than wpa_supplicant
653 * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
654 * will tricker Michael MIC errors. This can be fixed by changing the
655 * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
656 * in driver_*.c set_key() implementation, see driver_ndis.c for an
657 * example on how this can be done.
659 int (*set_key
)(const char *ifname
, void *priv
, enum wpa_alg alg
,
660 const u8
*addr
, int key_idx
, int set_tx
,
661 const u8
*seq
, size_t seq_len
,
662 const u8
*key
, size_t key_len
);
665 * init - Initialize driver interface
666 * @ctx: context to be used when calling wpa_supplicant functions,
667 * e.g., wpa_supplicant_event()
668 * @ifname: interface name, e.g., wlan0
670 * Returns: Pointer to private data, %NULL on failure
672 * Initialize driver interface, including event processing for kernel
673 * driver events (e.g., associated, scan results, Michael MIC failure).
674 * This function can allocate a private configuration data area for
675 * @ctx, file descriptor, interface name, etc. information that may be
676 * needed in future driver operations. If this is not used, non-NULL
677 * value will need to be returned because %NULL is used to indicate
678 * failure. The returned value will be used as 'void *priv' data for
679 * all other driver_ops functions.
681 * The main event loop (eloop.c) of wpa_supplicant can be used to
682 * register callback for read sockets (eloop_register_read_sock()).
684 * See below for more information about events and
685 * wpa_supplicant_event() function.
687 void * (*init
)(void *ctx
, const char *ifname
);
690 * deinit - Deinitialize driver interface
691 * @priv: private driver interface data from init()
693 * Shut down driver interface and processing of driver events. Free
694 * private data buffer if one was allocated in init() handler.
696 void (*deinit
)(void *priv
);
699 * set_param - Set driver configuration parameters
700 * @priv: private driver interface data from init()
701 * @param: driver specific configuration parameters
703 * Returns: 0 on success, -1 on failure
705 * Optional handler for notifying driver interface about configuration
706 * parameters (driver_param).
708 int (*set_param
)(void *priv
, const char *param
);
711 * set_countermeasures - Enable/disable TKIP countermeasures
712 * @priv: private driver interface data
713 * @enabled: 1 = countermeasures enabled, 0 = disabled
715 * Returns: 0 on success, -1 on failure
717 * Configure TKIP countermeasures. When these are enabled, the driver
718 * should drop all received and queued frames that are using TKIP.
720 int (*set_countermeasures
)(void *priv
, int enabled
);
723 * deauthenticate - Request driver to deauthenticate
724 * @priv: private driver interface data
725 * @addr: peer address (BSSID of the AP)
726 * @reason_code: 16-bit reason code to be sent in the deauthentication
729 * Returns: 0 on success, -1 on failure
731 int (*deauthenticate
)(void *priv
, const u8
*addr
, int reason_code
);
734 * disassociate - Request driver to disassociate
735 * @priv: private driver interface data
736 * @addr: peer address (BSSID of the AP)
737 * @reason_code: 16-bit reason code to be sent in the disassociation
740 * Returns: 0 on success, -1 on failure
742 int (*disassociate
)(void *priv
, const u8
*addr
, int reason_code
);
745 * associate - Request driver to associate
746 * @priv: private driver interface data
747 * @params: association parameters
749 * Returns: 0 on success, -1 on failure
751 int (*associate
)(void *priv
,
752 struct wpa_driver_associate_params
*params
);
755 * add_pmkid - Add PMKSA cache entry to the driver
756 * @priv: private driver interface data
757 * @bssid: BSSID for the PMKSA cache entry
758 * @pmkid: PMKID for the PMKSA cache entry
760 * Returns: 0 on success, -1 on failure
762 * This function is called when a new PMK is received, as a result of
763 * either normal authentication or RSN pre-authentication.
765 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
766 * associate(), add_pmkid() can be used to add new PMKSA cache entries
767 * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
768 * driver_ops function does not need to be implemented. Likewise, if
769 * the driver does not support WPA, this function is not needed.
771 int (*add_pmkid
)(void *priv
, const u8
*bssid
, const u8
*pmkid
);
774 * remove_pmkid - Remove PMKSA cache entry to the driver
775 * @priv: private driver interface data
776 * @bssid: BSSID for the PMKSA cache entry
777 * @pmkid: PMKID for the PMKSA cache entry
779 * Returns: 0 on success, -1 on failure
781 * This function is called when the supplicant drops a PMKSA cache
782 * entry for any reason.
784 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
785 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
786 * between the driver and wpa_supplicant. If the driver uses wpa_ie
787 * from wpa_supplicant, this driver_ops function does not need to be
788 * implemented. Likewise, if the driver does not support WPA, this
789 * function is not needed.
791 int (*remove_pmkid
)(void *priv
, const u8
*bssid
, const u8
*pmkid
);
794 * flush_pmkid - Flush PMKSA cache
795 * @priv: private driver interface data
797 * Returns: 0 on success, -1 on failure
799 * This function is called when the supplicant drops all PMKSA cache
800 * entries for any reason.
802 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
803 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
804 * between the driver and wpa_supplicant. If the driver uses wpa_ie
805 * from wpa_supplicant, this driver_ops function does not need to be
806 * implemented. Likewise, if the driver does not support WPA, this
807 * function is not needed.
809 int (*flush_pmkid
)(void *priv
);
812 * get_capa - Get driver capabilities
813 * @priv: private driver interface data
815 * Returns: 0 on success, -1 on failure
817 * Get driver/firmware/hardware capabilities.
819 int (*get_capa
)(void *priv
, struct wpa_driver_capa
*capa
);
822 * poll - Poll driver for association information
823 * @priv: private driver interface data
825 * This is an option callback that can be used when the driver does not
826 * provide event mechanism for association events. This is called when
827 * receiving WPA EAPOL-Key messages that require association
828 * information. The driver interface is supposed to generate associnfo
829 * event before returning from this callback function. In addition, the
830 * driver interface should generate an association event after having
831 * sent out associnfo.
833 void (*poll
)(void *priv
);
836 * get_ifname - Get interface name
837 * @priv: private driver interface data
839 * Returns: Pointer to the interface name. This can differ from the
840 * interface name used in init() call. Init() is called first.
842 * This optional function can be used to allow the driver interface to
843 * replace the interface name with something else, e.g., based on an
844 * interface mapping from a more descriptive name.
846 const char * (*get_ifname
)(void *priv
);
849 * get_mac_addr - Get own MAC address
850 * @priv: private driver interface data
852 * Returns: Pointer to own MAC address or %NULL on failure
854 * This optional function can be used to get the own MAC address of the
855 * device from the driver interface code. This is only needed if the
856 * l2_packet implementation for the OS does not provide easy access to
858 const u8
* (*get_mac_addr
)(void *priv
);
861 * send_eapol - Optional function for sending EAPOL packets
862 * @priv: private driver interface data
863 * @dest: Destination MAC address
865 * @data: EAPOL packet starting with IEEE 802.1X header
866 * @data_len: Size of the EAPOL packet
868 * Returns: 0 on success, -1 on failure
870 * This optional function can be used to override l2_packet operations
871 * with driver specific functionality. If this function pointer is set,
872 * l2_packet module is not used at all and the driver interface code is
873 * responsible for receiving and sending all EAPOL packets. The
874 * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
875 * event. The driver interface is required to implement get_mac_addr()
876 * handler if send_eapol() is used.
878 int (*send_eapol
)(void *priv
, const u8
*dest
, u16 proto
,
879 const u8
*data
, size_t data_len
);
882 * set_operstate - Sets device operating state to DORMANT or UP
883 * @priv: private driver interface data
884 * @state: 0 = dormant, 1 = up
885 * Returns: 0 on success, -1 on failure
887 * This is an optional function that can be used on operating systems
888 * that support a concept of controlling network device state from user
889 * space applications. This function, if set, gets called with
890 * state = 1 when authentication has been completed and with state = 0
891 * when connection is lost.
893 int (*set_operstate
)(void *priv
, int state
);
896 * mlme_setprotection - MLME-SETPROTECTION.request primitive
897 * @priv: Private driver interface data
898 * @addr: Address of the station for which to set protection (may be
899 * %NULL for group keys)
900 * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
901 * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
902 * Returns: 0 on success, -1 on failure
904 * This is an optional function that can be used to set the driver to
905 * require protection for Tx and/or Rx frames. This uses the layer
906 * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
907 * (MLME-SETPROTECTION.request). Many drivers do not use explicit
908 * set protection operation; instead, they set protection implicitly
909 * based on configured keys.
911 int (*mlme_setprotection
)(void *priv
, const u8
*addr
, int protect_type
,
915 * get_hw_feature_data - Get hardware support data (channels and rates)
916 * @priv: Private driver interface data
917 * @num_modes: Variable for returning the number of returned modes
918 * flags: Variable for returning hardware feature flags
919 * Returns: Pointer to allocated hardware data on success or %NULL on
920 * failure. Caller is responsible for freeing this.
922 * This function is only needed for drivers that export MLME
923 * (management frame processing) to %wpa_supplicant or hostapd.
925 struct hostapd_hw_modes
* (*get_hw_feature_data
)(void *priv
,
930 * set_channel - Set channel
931 * @priv: Private driver interface data
932 * @phymode: HOSTAPD_MODE_IEEE80211B, ..
933 * @chan: IEEE 802.11 channel number
934 * @freq: Frequency of the channel in MHz
935 * Returns: 0 on success, -1 on failure
937 * This function is only needed for drivers that export MLME
938 * (management frame processing) to wpa_supplicant.
940 int (*set_channel
)(void *priv
, enum hostapd_hw_mode phymode
, int chan
,
944 * set_ssid - Set SSID
945 * @priv: Private driver interface data
947 * @ssid_len: SSID length
948 * Returns: 0 on success, -1 on failure
950 * This function is only needed for drivers that export MLME
951 * (management frame processing) to wpa_supplicant.
953 int (*set_ssid
)(void *priv
, const u8
*ssid
, size_t ssid_len
);
956 * set_bssid - Set BSSID
957 * @priv: Private driver interface data
959 * Returns: 0 on success, -1 on failure
961 * This function is only needed for drivers that export MLME
962 * (management frame processing) to wpa_supplicant.
964 int (*set_bssid
)(void *priv
, const u8
*bssid
);
967 * send_mlme - Send management frame from MLME
968 * @priv: Private driver interface data
969 * @data: IEEE 802.11 management frame with IEEE 802.11 header
970 * @data_len: Size of the management frame
971 * Returns: 0 on success, -1 on failure
973 * This function is only needed for drivers that export MLME
974 * (management frame processing) to wpa_supplicant.
976 int (*send_mlme
)(void *priv
, const u8
*data
, size_t data_len
);
979 * mlme_add_sta - Add a STA entry into the driver/netstack
980 * @priv: Private driver interface data
981 * @addr: MAC address of the STA (e.g., BSSID of the AP)
982 * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
983 * format (one octet per rate, 1 = 0.5 Mbps)
984 * @supp_rates_len: Number of entries in supp_rates
985 * Returns: 0 on success, -1 on failure
987 * This function is only needed for drivers that export MLME
988 * (management frame processing) to wpa_supplicant. When the MLME code
989 * completes association with an AP, this function is called to
990 * configure the driver/netstack with a STA entry for data frame
991 * processing (TX rate control, encryption/decryption).
993 int (*mlme_add_sta
)(void *priv
, const u8
*addr
, const u8
*supp_rates
,
994 size_t supp_rates_len
);
997 * mlme_remove_sta - Remove a STA entry from the driver/netstack
998 * @priv: Private driver interface data
999 * @addr: MAC address of the STA (e.g., BSSID of the AP)
1000 * Returns: 0 on success, -1 on failure
1002 * This function is only needed for drivers that export MLME
1003 * (management frame processing) to wpa_supplicant.
1005 int (*mlme_remove_sta
)(void *priv
, const u8
*addr
);
1008 * update_ft_ies - Update FT (IEEE 802.11r) IEs
1009 * @priv: Private driver interface data
1010 * @md: Mobility domain (2 octets) (also included inside ies)
1011 * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
1012 * @ies_len: Length of FT IEs in bytes
1013 * Returns: 0 on success, -1 on failure
1015 * The supplicant uses this callback to let the driver know that keying
1016 * material for FT is available and that the driver can use the
1017 * provided IEs in the next message in FT authentication sequence.
1019 * This function is only needed for driver that support IEEE 802.11r
1020 * (Fast BSS Transition).
1022 int (*update_ft_ies
)(void *priv
, const u8
*md
, const u8
*ies
,
1026 * send_ft_action - Send FT Action frame (IEEE 802.11r)
1027 * @priv: Private driver interface data
1028 * @action: Action field value
1029 * @target_ap: Target AP address
1030 * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
1031 * @ies_len: Length of FT IEs in bytes
1032 * Returns: 0 on success, -1 on failure
1034 * The supplicant uses this callback to request the driver to transmit
1035 * an FT Action frame (action category 6) for over-the-DS fast BSS
1038 int (*send_ft_action
)(void *priv
, u8 action
, const u8
*target_ap
,
1039 const u8
*ies
, size_t ies_len
);
1042 * get_scan_results2 - Fetch the latest scan results
1043 * @priv: private driver interface data
1045 * Returns: Allocated buffer of scan results (caller is responsible for
1046 * freeing the data structure) on success, NULL on failure
1048 struct wpa_scan_results
* (*get_scan_results2
)(void *priv
);
1051 * set_country - Set country
1052 * @priv: Private driver interface data
1053 * @alpha2: country to which to switch to
1054 * Returns: 0 on success, -1 on failure
1056 * This function is for drivers which support some form
1057 * of setting a regulatory domain.
1059 int (*set_country
)(void *priv
, const char *alpha2
);
1062 * global_init - Global driver initialization
1063 * Returns: Pointer to private data (global), %NULL on failure
1065 * This optional function is called to initialize the driver wrapper
1066 * for global data, i.e., data that applies to all interfaces. If this
1067 * function is implemented, global_deinit() will also need to be
1068 * implemented to free the private data. The driver will also likely
1069 * use init2() function instead of init() to get the pointer to global
1070 * data available to per-interface initializer.
1072 void * (*global_init
)(void);
1075 * global_deinit - Global driver deinitialization
1076 * @priv: private driver global data from global_init()
1078 * Terminate any global driver related functionality and free the
1079 * global data structure.
1081 void (*global_deinit
)(void *priv
);
1084 * init2 - Initialize driver interface (with global data)
1085 * @ctx: context to be used when calling wpa_supplicant functions,
1086 * e.g., wpa_supplicant_event()
1087 * @ifname: interface name, e.g., wlan0
1088 * @global_priv: private driver global data from global_init()
1089 * Returns: Pointer to private data, %NULL on failure
1091 * This function can be used instead of init() if the driver wrapper
1094 void * (*init2
)(void *ctx
, const char *ifname
, void *global_priv
);
1097 * get_interfaces - Get information about available interfaces
1098 * @global_priv: private driver global data from global_init()
1099 * Returns: Allocated buffer of interface information (caller is
1100 * responsible for freeing the data structure) on success, NULL on
1103 struct wpa_interface_info
* (*get_interfaces
)(void *global_priv
);
1106 * scan2 - Request the driver to initiate scan
1107 * @priv: private driver interface data
1108 * @params: Scan parameters
1110 * Returns: 0 on success, -1 on failure
1112 * Once the scan results are ready, the driver should report scan
1113 * results event for wpa_supplicant which will eventually request the
1114 * results with wpa_driver_get_scan_results2().
1116 int (*scan2
)(void *priv
, struct wpa_driver_scan_params
*params
);
1119 * authenticate - Request driver to authenticate
1120 * @priv: private driver interface data
1121 * @params: authentication parameters
1122 * Returns: 0 on success, -1 on failure
1124 * This is an optional function that can be used with drivers that
1125 * support separate authentication and association steps, i.e., when
1126 * wpa_supplicant can act as the SME. If not implemented, associate()
1127 * function is expected to take care of IEEE 802.11 authentication,
1130 int (*authenticate
)(void *priv
,
1131 struct wpa_driver_auth_params
*params
);
1134 * set_beacon - Set Beacon frame template
1135 * @iface: Interface name (main interface or virtual BSS)
1136 * @priv: Private driver interface data
1137 * @head: Beacon head from IEEE 802.11 header to IEs before TIM IE
1138 * @head_len: Length of the head buffer in octets
1139 * @tail: Beacon tail following TIM IE
1140 * @tail_len: Length of the tail buffer in octets
1141 * @dtim_period: DTIM period
1142 * @beacon_int: Beacon interval
1143 * Returns: 0 on success, -1 on failure
1145 * This function is used to configure Beacon template for the driver in
1146 * AP mode. The driver is responsible for building the full Beacon
1147 * frame by concatenating the head part with TIM IE generated by the
1148 * driver/firmware and finishing with the tail part.
1150 int (*set_beacon
)(const char *ifname
, void *priv
,
1151 const u8
*head
, size_t head_len
,
1152 const u8
*tail
, size_t tail_len
, int dtim_period
,
1156 * hapd_init - Initialize driver interface (hostapd only)
1157 * @hapd: Pointer to hostapd context
1158 * @params: Configuration for the driver wrapper
1159 * Returns: Pointer to private data, %NULL on failure
1161 * This function is used instead of init() or init2() when the driver
1162 * wrapper is used withh hostapd.
1164 void * (*hapd_init
)(struct hostapd_data
*hapd
,
1165 struct wpa_init_params
*params
);
1168 * hapd_deinit - Deinitialize driver interface (hostapd only)
1169 * @priv: Private driver interface data from hapd_init()
1171 void (*hapd_deinit
)(void *priv
);
1174 * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
1175 * @priv: Private driver interface data
1176 * @params: BSS parameters
1177 * Returns: 0 on success, -1 on failure
1179 * This is an optional function to configure the kernel driver to
1180 * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
1181 * can be left undefined (set to %NULL) if IEEE 802.1X support is
1182 * always enabled and the driver uses set_beacon() to set WPA/RSN IE
1183 * for Beacon frames.
1185 int (*set_ieee8021x
)(void *priv
, struct wpa_bss_params
*params
);
1188 * set_privacy - Enable/disable privacy (AP only)
1189 * @priv: Private driver interface data
1190 * @enabled: 1 = privacy enabled, 0 = disabled
1191 * Returns: 0 on success, -1 on failure
1193 * This is an optional function to configure privacy field in the
1194 * kernel driver for Beacon frames. This can be left undefined (set to
1195 * %NULL) if the driver uses the Beacon template from set_beacon().
1197 int (*set_privacy
)(const char *ifname
, void *priv
, int enabled
);
1200 * get_seqnum - Fetch the current TSC/packet number (AP only)
1201 * @ifname: The interface name (main or virtual)
1202 * @priv: Private driver interface data
1203 * @addr: MAC address of the station or %NULL for group keys
1205 * @seq: Buffer for returning the latest used TSC/packet number
1206 * Returns: 0 on success, -1 on failure
1208 * This function is used to fetch the last used TSC/packet number for
1209 * a TKIP, CCMP, or BIP/IGTK key. It is mainly used with group keys, so
1210 * there is no strict requirement on implementing support for unicast
1211 * keys (i.e., addr != %NULL).
1213 int (*get_seqnum
)(const char *ifname
, void *priv
, const u8
*addr
,
1217 * flush - Flush all association stations (AP only)
1218 * @priv: Private driver interface data
1219 * Returns: 0 on success, -1 on failure
1221 * This function requests the driver to disassociate all associated
1222 * stations. This function does not need to be implemented if the
1223 * driver does not process association frames internally.
1225 int (*flush
)(void *priv
);
1228 * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
1229 * @ifname: The interface name (main or virtual BSS)
1230 * @priv: Private driver interface data
1231 * @elem: Information elements
1232 * @elem_len: Length of the elem buffer in octets
1233 * Returns: 0 on success, -1 on failure
1235 * This is an optional function to add information elements in the
1236 * kernel driver for Beacon and Probe Response frames. This can be left
1237 * undefined (set to %NULL) if the driver uses the Beacon template from
1240 int (*set_generic_elem
)(const char *ifname
, void *priv
, const u8
*elem
,
1244 * read_sta_data - Fetch station data (AP only)
1245 * @priv: Private driver interface data
1246 * @data: Buffer for returning station information
1247 * @addr: MAC address of the station
1248 * Returns: 0 on success, -1 on failure
1250 int (*read_sta_data
)(void *priv
, struct hostap_sta_driver_data
*data
,
1254 * hapd_send_eapol - Send an EAPOL packet (AP only)
1255 * @priv: private driver interface data
1256 * @addr: Destination MAC address
1257 * @data: EAPOL packet starting with IEEE 802.1X header
1258 * @data_len: Length of the EAPOL packet in octets
1259 * @encrypt: Whether the frame should be encrypted
1260 * @own_addr: Source MAC address
1262 * Returns: 0 on success, -1 on failure
1264 int (*hapd_send_eapol
)(void *priv
, const u8
*addr
, const u8
*data
,
1265 size_t data_len
, int encrypt
,
1266 const u8
*own_addr
);
1269 * sta_deauth - Deauthenticate a station (AP only)
1270 * @priv: Private driver interface data
1271 * @own_addr: Source address and BSSID for the Deauthentication frame
1272 * @addr: MAC address of the station to deauthenticate
1273 * @reason: Reason code for the Deauthentiation frame
1274 * Returns: 0 on success, -1 on failure
1276 * This function requests a specific station to be deauthenticated and
1277 * a Deauthentication frame to be sent to it.
1279 int (*sta_deauth
)(void *priv
, const u8
*own_addr
, const u8
*addr
,
1283 * sta_disassoc - Disassociate a station (AP only)
1284 * @priv: Private driver interface data
1285 * @own_addr: Source address and BSSID for the Disassociation frame
1286 * @addr: MAC address of the station to disassociate
1287 * @reason: Reason code for the Disassociation frame
1288 * Returns: 0 on success, -1 on failure
1290 * This function requests a specific station to be disassociated and
1291 * a Disassociation frame to be sent to it.
1293 int (*sta_disassoc
)(void *priv
, const u8
*own_addr
, const u8
*addr
,
1297 * sta_remove - Remove a station entry (AP only)
1298 * @priv: Private driver interface data
1299 * @addr: MAC address of the station to be removed
1300 * Returns: 0 on success, -1 on failure
1302 int (*sta_remove
)(void *priv
, const u8
*addr
);
1305 * hapd_get_ssid - Get the current SSID (AP only)
1306 * @ifname: Interface (master or virtual BSS)
1307 * @priv: Private driver interface data
1308 * @buf: Buffer for returning the SSID
1309 * @len: Maximum length of the buffer
1310 * Returns: Length of the SSID on success, -1 on failure
1312 * This function need not be implemented if the driver uses Beacon
1313 * template from set_beacon() and does not reply to Probe Request
1316 int (*hapd_get_ssid
)(const char *ifname
, void *priv
, u8
*buf
, int len
);
1319 * hapd_set_ssid - Set SSID (AP only)
1320 * @ifname: Interface (master or virtual BSS)
1321 * @priv: Private driver interface data
1323 * @len: Length of the SSID in octets
1324 * Returns: 0 on success, -1 on failure
1326 int (*hapd_set_ssid
)(const char *ifname
, void *priv
, const u8
*buf
,
1329 * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
1330 * @priv: Private driver interface data
1331 * @enabled: 1 = countermeasures enabled, 0 = disabled
1332 * Returns: 0 on success, -1 on failure
1334 * This need not be implemented if the driver does not take care of
1335 * association processing.
1337 int (*hapd_set_countermeasures
)(void *priv
, int enabled
);
1340 * sta_add - Add a station entry
1341 * @ifname: Interface (master or virtual)
1342 * @priv: Private driver interface data
1343 * @params: Station parameters
1344 * Returns: 0 on success, -1 on failure
1346 * This function is used to add a station entry to the driver once the
1347 * station has completed association. This is only used if the driver
1348 * does not take care of association processing.
1350 int (*sta_add
)(const char *ifname
, void *priv
,
1351 struct hostapd_sta_add_params
*params
);
1354 * get_inact_sec - Get station inactivity duration (AP only)
1355 * @priv: Private driver interface data
1356 * @addr: Station address
1357 * Returns: Number of seconds station has been inactive, -1 on failure
1359 int (*get_inact_sec
)(void *priv
, const u8
*addr
);
1362 * sta_clear_stats - Clear station statistics (AP only)
1363 * @priv: Private driver interface data
1364 * @addr: Station address
1365 * Returns: 0 on success, -1 on failure
1367 int (*sta_clear_stats
)(void *priv
, const u8
*addr
);
1370 * set_freq - Set channel/frequency (AP only)
1371 * @priv: Private driver interface data
1372 * @freq: Channel parameters
1373 * Returns: 0 on success, -1 on failure
1375 int (*set_freq
)(void *priv
, struct hostapd_freq_params
*freq
);
1378 * set_rts - Set RTS threshold
1379 * @priv: Private driver interface data
1380 * @rts: RTS threshold in octets
1381 * Returns: 0 on success, -1 on failure
1383 int (*set_rts
)(void *priv
, int rts
);
1386 * set_frag - Set fragmentation threshold
1387 * @priv: Private driver interface data
1388 * @frag: Fragmentation threshold in octets
1389 * Returns: 0 on success, -1 on failure
1391 int (*set_frag
)(void *priv
, int frag
);
1394 * sta_set_flags - Set station flags (AP only)
1395 * @priv: Private driver interface data
1396 * @addr: Station address
1397 * @total_flags: Bitmap of all WPA_STA_* flags currently set
1398 * @flags_or: Bitmap of WPA_STA_* flags to add
1399 * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
1400 * Returns: 0 on success, -1 on failure
1402 int (*sta_set_flags
)(void *priv
, const u8
*addr
,
1403 int total_flags
, int flags_or
, int flags_and
);
1406 * set_rate_sets - Set supported and basic rate sets (AP only)
1407 * @priv: Private driver interface data
1408 * @supp_rates: -1 terminated array of supported rates in 100 kbps
1409 * @basic_rates: -1 terminated array of basic rates in 100 kbps
1410 * @mode: hardware mode (HOSTAPD_MODE_*)
1411 * Returns: 0 on success, -1 on failure
1413 int (*set_rate_sets
)(void *priv
, int *supp_rates
, int *basic_rates
,
1417 * set_cts_protect - Set CTS protection mode (AP only)
1418 * @priv: Private driver interface data
1419 * @value: Whether CTS protection is enabled
1420 * Returns: 0 on success, -1 on failure
1422 int (*set_cts_protect
)(void *priv
, int value
);
1425 * set_preamble - Set preamble mode (AP only)
1426 * @priv: Private driver interface data
1427 * @value: Whether short preamble is enabled
1428 * Returns: 0 on success, -1 on failure
1430 int (*set_preamble
)(void *priv
, int value
);
1433 * set_short_slot_time - Set short slot time (AP only)
1434 * @priv: Private driver interface data
1435 * @value: Whether short slot time is enabled
1436 * Returns: 0 on success, -1 on failure
1438 int (*set_short_slot_time
)(void *priv
, int value
);
1441 * set_tx_queue_params - Set TX queue parameters
1442 * @priv: Private driver interface data
1443 * @queue: Queue number
1447 * @burst_time: Maximum length for bursting in 0.1 msec units
1449 int (*set_tx_queue_params
)(void *priv
, int queue
, int aifs
, int cw_min
,
1450 int cw_max
, int burst_time
);
1453 * valid_bss_mask - Validate BSSID mask
1454 * @priv: Private driver interface data
1457 * Returns: 0 if mask is valid, -1 if mask is not valid, 1 if mask can
1458 * be used, but the main interface address must be the first address in
1459 * the block if mask is applied
1461 int (*valid_bss_mask
)(void *priv
, const u8
*addr
, const u8
*mask
);
1464 * if_add - Add a virtual interface
1465 * @iface: Parent interface name
1466 * @priv: Private driver interface data
1467 * @type: Interface type
1468 * @ifname: Interface name for the new virtual interface
1469 * @addr: Local address to use for the interface or %NULL to use the
1470 * parent interface address
1471 * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
1472 * Returns: 0 on success, -1 on failure
1474 int (*if_add
)(const char *iface
, void *priv
,
1475 enum wpa_driver_if_type type
, const char *ifname
,
1476 const u8
*addr
, void *bss_ctx
);
1479 * if_remove - Remove a virtual interface
1480 * @priv: Private driver interface data
1481 * @type: Interface type
1482 * @ifname: Interface name of the virtual interface to be removed
1483 * Returns: 0 on success, -1 on failure
1485 int (*if_remove
)(void *priv
, enum wpa_driver_if_type type
,
1486 const char *ifname
);
1489 * set_sta_vlan - Bind a station into a specific interface (AP only)
1490 * @priv: Private driver interface data
1491 * @ifname: Interface (main or virtual BSS or VLAN)
1492 * @addr: MAC address of the associated station
1494 * Returns: 0 on success, -1 on failure
1496 * This function is used to bind a station to a specific virtual
1497 * interface. It is only used if when virtual interfaces are supported,
1498 * e.g., to assign stations to different VLAN interfaces based on
1499 * information from a RADIUS server. This allows separate broadcast
1500 * domains to be used with a single BSS.
1502 int (*set_sta_vlan
)(void *priv
, const u8
*addr
, const char *ifname
,
1506 * commit - Optional commit changes handler (AP only)
1507 * @priv: driver private data
1508 * Returns: 0 on success, -1 on failure
1510 * This optional handler function can be registered if the driver
1511 * interface implementation needs to commit changes (e.g., by setting
1512 * network interface up) at the end of initial configuration. If set,
1513 * this handler will be called after initial setup has been completed.
1515 int (*commit
)(void *priv
);
1518 * send_ether - Send an ethernet packet (AP only)
1519 * @priv: private driver interface data
1520 * @dst: Destination MAC address
1521 * @src: Source MAC address
1523 * @data: EAPOL packet starting with IEEE 802.1X header
1524 * @data_len: Length of the EAPOL packet in octets
1525 * Returns: 0 on success, -1 on failure
1527 int (*send_ether
)(void *priv
, const u8
*dst
, const u8
*src
, u16 proto
,
1528 const u8
*data
, size_t data_len
);
1531 * set_radius_acl_auth - Notification of RADIUS ACL change
1532 * @priv: Private driver interface data
1533 * @mac: MAC address of the station
1534 * @accepted: Whether the station was accepted
1535 * @session_timeout: Session timeout for the station
1536 * Returns: 0 on success, -1 on failure
1538 int (*set_radius_acl_auth
)(void *priv
, const u8
*mac
, int accepted
,
1539 u32 session_timeout
);
1542 * set_radius_acl_expire - Notification of RADIUS ACL expiration
1543 * @priv: Private driver interface data
1544 * @mac: MAC address of the station
1545 * Returns: 0 on success, -1 on failure
1547 int (*set_radius_acl_expire
)(void *priv
, const u8
*mac
);
1550 * set_ht_params - Set HT parameters (AP only)
1551 * @ifname: The interface name (main or virtual BSS)
1552 * @priv: Private driver interface data
1553 * @ht_capab: HT Capabilities IE
1554 * @ht_capab_len: Length of ht_capab in octets
1555 * @ht_oper: HT Operation IE
1556 * @ht_oper_len: Length of ht_oper in octets
1557 * Returns: 0 on success, -1 on failure
1559 int (*set_ht_params
)(const char *ifname
, void *priv
,
1560 const u8
*ht_capab
, size_t ht_capab_len
,
1561 const u8
*ht_oper
, size_t ht_oper_len
);
1564 * set_ap_wps_ie - Add WPS IE into Beacon/Probe Response frames (AP)
1565 * @ifname: The interface name (main or virtual BSS)
1566 * @priv: Private driver interface data
1567 * @beacon: WPS IE for Beacon frames
1568 * @proberesp: WPS IE for Probe Response frames
1569 * Returns: 0 on success, -1 on failure
1571 * This is an optional function to add WPS IE in the kernel driver for
1572 * Beacon and Probe Response frames. This can be left undefined (set
1573 * to %NULL) if the driver uses the Beacon template from set_beacon()
1574 * and does not process Probe Request frames.
1576 int (*set_ap_wps_ie
)(const char *ifname
, void *priv
,
1577 const struct wpabuf
*beacon
,
1578 const struct wpabuf
*proberesp
);
1581 * set_supp_port - Set IEEE 802.1X Supplicant Port status
1582 * @priv: Private driver interface data
1583 * @authorized: Whether the port is authorized
1584 * Returns: 0 on success, -1 on failure
1586 int (*set_supp_port
)(void *priv
, int authorized
);
1589 * set_wds_sta - Bind a station into a 4-address WDS (AP only)
1590 * @priv: Private driver interface data
1591 * @addr: MAC address of the associated station
1592 * @aid: Association ID
1593 * @val: 1 = bind to 4-address WDS; 0 = unbind
1594 * Returns: 0 on success, -1 on failure
1596 int (*set_wds_sta
)(void *priv
, const u8
*addr
, int aid
, int val
);
1599 * send_action - Transmit an Action frame
1600 * @priv: Private driver interface data
1601 * @freq: Frequency (in MHz) of the channel
1602 * @dst: Destination MAC address
1603 * @src: Source MAC address
1605 * @data_len: data length in octets
1606 * Returns: 0 on success, -1 on failure
1608 * This command can be used to request the driver to transmit an action
1609 * frame to the specified destination. If a remain-on-channel duration
1610 * is in progress, the frame is transmitted on that channel. Otherwise,
1611 * the frame is transmitted on the current operational channel if in
1612 * associated state in station mode or if operating as an AP. If none
1613 * of these conditions is in effect, send_action() cannot be used.
1615 int (*send_action
)(void *priv
, unsigned int freq
,
1616 const u8
*dst
, const u8
*src
,
1617 const u8
*data
, size_t data_len
);
1620 * alloc_interface_addr - Allocate a virtual interface address
1621 * @priv: Private driver interface data
1622 * @addr: Buffer for returning the address
1623 * Returns: 0 on success, -1 on failure
1625 * This command pre-allocates an interface address for a new virtual
1626 * interface. This can be used before creating a virtual interface if
1627 * the interface mode (e.g., AP vs. station) is not yet known, but the
1628 * address of the virtual interface is already needed. This helps with
1629 * drivers that cannot change interface mode without destroying and
1630 * re-creating the interface.
1632 * The allocated address can be used in a bss_add() call to request a
1635 int (*alloc_interface_addr
)(void *priv
, u8
*addr
);
1638 * release_interface_addr - Release a virtual interface address
1639 * @priv: Private driver interface data
1640 * @addr: Address to be freed from alloc_interface_addr()
1642 * This command is used to release a virtual interface address that was
1643 * allocated with alloc_interface_addr(), but has not yet been used
1644 * with bss_add() to actually create the interface. This allows the
1645 * driver to release the pending allocation for a new interface.
1647 void (*release_interface_addr
)(void *priv
, const u8
*addr
);
1650 * remain_on_channel - Remain awake on a channel
1651 * @priv: Private driver interface data
1652 * @freq: Frequency (in MHz) of the channel
1653 * @duration: Duration in milliseconds
1654 * Returns: 0 on success, -1 on failure
1656 * This command is used to request the driver to remain awake on the
1657 * specified channel for the specified duration and report received
1658 * Action frames with EVENT_RX_ACTION events. Optionally, received
1659 * Probe Request frames may also be requested to be reported by calling
1660 * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
1662 * The driver may not be at the requested channel when this function
1663 * returns, i.e., the return code is only indicating whether the
1664 * request was accepted. The caller will need to wait until the
1665 * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
1666 * completed the channel change. This may take some time due to other
1667 * need for the radio and the caller should be prepared to timing out
1668 * its wait since there are no guarantees on when this request can be
1671 int (*remain_on_channel
)(void *priv
, unsigned int freq
,
1672 unsigned int duration
);
1675 * cancel_remain_on_channel - Cancel remain-on-channel operation
1676 * @priv: Private driver interface data
1678 * This command can be used to cancel a remain-on-channel operation
1679 * before its originally requested duration has passed. This could be
1680 * used, e.g., when remain_on_channel() is used to request extra time
1681 * to receive a response to an Action frame and the response is
1682 * received when there is still unneeded time remaining on the
1683 * remain-on-channel operation.
1685 int (*cancel_remain_on_channel
)(void *priv
);
1688 * probe_req_report - Request Probe Request frames to be indicated
1689 * @priv: Private driver interface data
1690 * @report: Whether to report received Probe Request frames
1691 * Returns: 0 on success, -1 on failure (or if not supported)
1693 * This command can be used to request the driver to indicate when
1694 * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
1695 * Since this operation may require extra resources, e.g., due to less
1696 * optimal hardware/firmware RX filtering, many drivers may disable
1697 * Probe Request reporting at least in station mode. This command is
1698 * used to notify the driver when the Probe Request frames need to be
1699 * reported, e.g., during remain-on-channel operations.
1701 int (*probe_req_report
)(void *priv
, int report
);
1706 * enum wpa_event_type - Event type for wpa_supplicant_event() calls
1708 enum wpa_event_type
{
1710 * EVENT_ASSOC - Association completed
1712 * This event needs to be delivered when the driver completes IEEE
1713 * 802.11 association or reassociation successfully.
1714 * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
1715 * after this event has been generated. In addition, optional
1716 * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
1717 * more information about the association. If the driver interface gets
1718 * both of these events at the same time, it can also include the
1719 * assoc_info data in EVENT_ASSOC call.
1724 * EVENT_DISASSOC - Association lost
1726 * This event should be called when association is lost either due to
1727 * receiving deauthenticate or disassociate frame from the AP or when
1728 * sending either of these frames to the current AP. If the driver
1729 * supports separate deauthentication event, EVENT_DISASSOC should only
1730 * be used for disassociation and EVENT_DEAUTH for deauthentication.
1731 * In AP mode, union wpa_event_data::disassoc_info is required.
1736 * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
1738 * This event must be delivered when a Michael MIC error is detected by
1739 * the local driver. Additional data for event processing is
1740 * provided with union wpa_event_data::michael_mic_failure. This
1741 * information is used to request new encyption key and to initiate
1742 * TKIP countermeasures if needed.
1744 EVENT_MICHAEL_MIC_FAILURE
,
1747 * EVENT_SCAN_RESULTS - Scan results available
1749 * This event must be called whenever scan results are available to be
1750 * fetched with struct wpa_driver_ops::get_scan_results(). This event
1751 * is expected to be used some time after struct wpa_driver_ops::scan()
1752 * is called. If the driver provides an unsolicited event when the scan
1753 * has been completed, this event can be used to trigger
1754 * EVENT_SCAN_RESULTS call. If such event is not available from the
1755 * driver, the driver wrapper code is expected to use a registered
1756 * timeout to generate EVENT_SCAN_RESULTS call after the time that the
1757 * scan is expected to be completed. Optional information about
1758 * completed scan can be provided with union wpa_event_data::scan_info.
1763 * EVENT_ASSOCINFO - Report optional extra information for association
1765 * This event can be used to report extra association information for
1766 * EVENT_ASSOC processing. This extra information includes IEs from
1767 * association frames and Beacon/Probe Response frames in union
1768 * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
1769 * EVENT_ASSOC. Alternatively, the driver interface can include
1770 * assoc_info data in the EVENT_ASSOC call if it has all the
1771 * information available at the same point.
1776 * EVENT_INTERFACE_STATUS - Report interface status changes
1778 * This optional event can be used to report changes in interface
1779 * status (interface added/removed) using union
1780 * wpa_event_data::interface_status. This can be used to trigger
1781 * wpa_supplicant to stop and re-start processing for the interface,
1782 * e.g., when a cardbus card is ejected/inserted.
1784 EVENT_INTERFACE_STATUS
,
1787 * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
1789 * This event can be used to inform wpa_supplicant about candidates for
1790 * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
1791 * for scan request (ap_scan=2 mode), this event is required for
1792 * pre-authentication. If wpa_supplicant is performing scan request
1793 * (ap_scan=1), this event is optional since scan results can be used
1794 * to add pre-authentication candidates. union
1795 * wpa_event_data::pmkid_candidate is used to report the BSSID of the
1796 * candidate and priority of the candidate, e.g., based on the signal
1797 * strength, in order to try to pre-authenticate first with candidates
1798 * that are most likely targets for re-association.
1800 * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
1801 * on the candidate list. In addition, it can be called for the current
1802 * AP and APs that have existing PMKSA cache entries. wpa_supplicant
1803 * will automatically skip pre-authentication in cases where a valid
1804 * PMKSA exists. When more than one candidate exists, this event should
1805 * be generated once for each candidate.
1807 * Driver will be notified about successful pre-authentication with
1808 * struct wpa_driver_ops::add_pmkid() calls.
1810 EVENT_PMKID_CANDIDATE
,
1813 * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
1815 * This event can be used to inform wpa_supplicant about desire to set
1816 * up secure direct link connection between two stations as defined in
1817 * IEEE 802.11e with a new PeerKey mechanism that replaced the original
1818 * STAKey negotiation. The caller will need to set peer address for the
1824 * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
1826 * The driver is expected to report the received FT IEs from
1827 * FT authentication sequence from the AP. The FT IEs are included in
1828 * the extra information in union wpa_event_data::ft_ies.
1833 * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
1835 * The driver can use this event to inform wpa_supplicant about a STA
1836 * in an IBSS with which protected frames could be exchanged. This
1837 * event starts RSN authentication with the other STA to authenticate
1838 * the STA and set up encryption keys with it.
1840 EVENT_IBSS_RSN_START
,
1843 * EVENT_AUTH - Authentication result
1845 * This event should be called when authentication attempt has been
1846 * completed. This is only used if the driver supports separate
1847 * authentication step (struct wpa_driver_ops::authenticate).
1848 * Information about authentication result is included in
1849 * union wpa_event_data::auth.
1854 * EVENT_DEAUTH - Authentication lost
1856 * This event should be called when authentication is lost either due
1857 * to receiving deauthenticate frame from the AP or when sending that
1858 * frame to the current AP.
1859 * In AP mode, union wpa_event_data::deauth_info is required.
1864 * EVENT_ASSOC_REJECT - Association rejected
1866 * This event should be called when (re)association attempt has been
1867 * rejected by the AP. Information about authentication result is
1868 * included in union wpa_event_data::assoc_reject.
1873 * EVENT_AUTH_TIMED_OUT - Authentication timed out
1875 EVENT_AUTH_TIMED_OUT
,
1878 * EVENT_ASSOC_TIMED_OUT - Association timed out
1880 EVENT_ASSOC_TIMED_OUT
,
1883 * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
1888 * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
1890 EVENT_WPS_BUTTON_PUSHED
,
1893 * EVENT_TX_STATUS - Report TX status
1898 * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
1900 EVENT_RX_FROM_UNKNOWN
,
1903 * EVENT_RX_MGMT - Report RX of a management frame
1908 * EVENT_RX_ACTION - Action frame received
1910 * This event is used to indicate when an Action frame has been
1911 * received. Information about the received frame is included in
1912 * union wpa_event_data::rx_action.
1917 * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
1919 * This event is used to indicate when the driver has started the
1920 * requested remain-on-channel duration. Information about the
1921 * operation is included in union wpa_event_data::remain_on_channel.
1923 EVENT_REMAIN_ON_CHANNEL
,
1926 * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
1928 * This event is used to indicate when the driver has completed
1929 * remain-on-channel duration, i.e., may noot be available on the
1930 * requested channel anymore. Information about the
1931 * operation is included in union wpa_event_data::remain_on_channel.
1933 EVENT_CANCEL_REMAIN_ON_CHANNEL
,
1936 * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
1938 * This event is used only by driver_test.c and userspace MLME.
1943 * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
1945 * This event is used to indicate when a Probe Request frame has been
1946 * received. Information about the received frame is included in
1947 * union wpa_event_data::rx_probe_req. The driver is required to report
1948 * these events only after successfully completed probe_req_report()
1949 * commands to request the events (i.e., report parameter is non-zero)
1950 * in station mode. In AP mode, Probe Request frames should always be
1956 * EVENT_NEW_STA - New wired device noticed
1958 * This event is used to indicate that a new device has been detected
1959 * in a network that does not use association-like functionality (i.e.,
1960 * mainly wired Ethernet). This can be used to start EAPOL
1961 * authenticator when receiving a frame from a device. The address of
1962 * the device is included in union wpa_event_data::new_sta.
1967 * EVENT_EAPOL_RX - Report received EAPOL frame
1969 * When in AP mode with hostapd, this event is required to be used to
1970 * deliver the receive EAPOL frames from the driver. With
1971 * %wpa_supplicant, this event is used only if the send_eapol() handler
1972 * is used to override the use of l2_packet for EAPOL frame TX.
1979 * union wpa_event_data - Additional data for wpa_supplicant_event() calls
1981 union wpa_event_data
{
1983 * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
1985 * This structure is optional for EVENT_ASSOC calls and required for
1986 * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
1987 * driver interface does not need to generate separate EVENT_ASSOCINFO
1992 * req_ies - (Re)Association Request IEs
1994 * If the driver generates WPA/RSN IE, this event data must be
1995 * returned for WPA handshake to have needed information. If
1996 * wpa_supplicant-generated WPA/RSN IE is used, this
1997 * information event is optional.
1999 * This should start with the first IE (fixed fields before IEs
2000 * are not included).
2005 * req_ies_len - Length of req_ies in bytes
2010 * resp_ies - (Re)Association Response IEs
2012 * Optional association data from the driver. This data is not
2013 * required WPA, but may be useful for some protocols and as
2014 * such, should be reported if this is available to the driver
2017 * This should start with the first IE (fixed fields before IEs
2018 * are not included).
2023 * resp_ies_len - Length of resp_ies in bytes
2025 size_t resp_ies_len
;
2028 * beacon_ies - Beacon or Probe Response IEs
2030 * Optional Beacon/ProbeResp data: IEs included in Beacon or
2031 * Probe Response frames from the current AP (i.e., the one
2032 * that the client just associated with). This information is
2033 * used to update WPA/RSN IE for the AP. If this field is not
2034 * set, the results from previous scan will be used. If no
2035 * data for the new AP is found, scan results will be requested
2036 * again (without scan request). At this point, the driver is
2037 * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
2040 * This should start with the first IE (fixed fields before IEs
2041 * are not included).
2043 const u8
*beacon_ies
;
2046 * beacon_ies_len - Length of beacon_ies */
2047 size_t beacon_ies_len
;
2050 * freq - Frequency of the operational channel in MHz
2055 * addr - Station address (for AP mode)
2061 * struct disassoc_info - Data for EVENT_DISASSOC events
2063 struct disassoc_info
{
2065 * addr - Station address (for AP mode)
2071 * struct deauth_info - Data for EVENT_DEAUTH events
2073 struct deauth_info
{
2075 * addr - Station address (for AP mode)
2081 * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
2083 struct michael_mic_failure
{
2086 } michael_mic_failure
;
2089 * struct interface_status - Data for EVENT_INTERFACE_STATUS
2091 struct interface_status
{
2094 EVENT_INTERFACE_ADDED
, EVENT_INTERFACE_REMOVED
2099 * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
2101 struct pmkid_candidate
{
2102 /** BSSID of the PMKID candidate */
2104 /** Smaller the index, higher the priority */
2106 /** Whether RSN IE includes pre-authenticate flag */
2111 * struct stkstart - Data for EVENT_STKSTART
2118 * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
2120 * During FT (IEEE 802.11r) authentication sequence, the driver is
2121 * expected to use this event to report received FT IEs (MDIE, FTIE,
2122 * RSN IE, TIE, possible resource request) to the supplicant. The FT
2123 * IEs for the next message will be delivered through the
2124 * struct wpa_driver_ops::update_ft_ies() callback.
2130 u8 target_ap
[ETH_ALEN
];
2131 /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
2133 /** Length of ric_ies buffer in octets */
2138 * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
2140 struct ibss_rsn_start
{
2145 * struct auth_info - Data for EVENT_AUTH events
2156 * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
2158 struct assoc_reject
{
2160 * resp_ies - (Re)Association Response IEs
2162 * Optional association data from the driver. This data is not
2163 * required WPA, but may be useful for some protocols and as
2164 * such, should be reported if this is available to the driver
2167 * This should start with the first IE (fixed fields before IEs
2168 * are not included).
2173 * resp_ies_len - Length of resp_ies in bytes
2175 size_t resp_ies_len
;
2178 * status_code - Status Code from (Re)association Response
2183 struct timeout_event
{
2188 * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
2197 * struct tx_status - Data for EVENT_TX_STATUS events
2209 * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
2211 struct rx_from_unknown
{
2217 * struct rx_mgmt - Data for EVENT_RX_MGMT events
2227 * struct rx_action - Data for EVENT_RX_ACTION events
2231 * sa - Source address of the received Action frame
2236 * category - Action frame category
2241 * data - Action frame body after category field
2246 * len - Length of data in octets
2251 * freq - Frequency (in MHz) on which the frame was received
2257 * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
2259 * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
2261 struct remain_on_channel
{
2263 * freq - Channel frequency in MHz
2268 * duration - Duration to remain on the channel in milliseconds
2270 unsigned int duration
;
2271 } remain_on_channel
;
2274 * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
2275 * @aborted: Whether the scan was aborted
2276 * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
2277 * @num_freqs: Number of entries in freqs array
2278 * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
2280 * @num_ssids: Number of entries in ssids array
2286 struct wpa_driver_scan_ssid ssids
[WPAS_MAX_SCAN_SSIDS
];
2291 * struct mlme_rx - Data for EVENT_MLME_RX events
2302 * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
2304 struct rx_probe_req
{
2306 * sa - Source address of the received Probe Request frame
2311 * ie - IEs from the Probe Request body
2316 * ie_len - Length of ie buffer in octets
2322 * struct new_sta - Data for EVENT_NEW_STA events
2329 * struct eapol_rx - Data for EVENT_EAPOL_RX events
2339 * wpa_supplicant_event - Report a driver event for wpa_supplicant
2340 * @ctx: Context pointer (wpa_s); this is the ctx variable registered
2341 * with struct wpa_driver_ops::init()
2342 * @event: event type (defined above)
2343 * @data: possible extra data for the event
2345 * Driver wrapper code should call this function whenever an event is received
2348 void wpa_supplicant_event(void *ctx
, enum wpa_event_type event
,
2349 union wpa_event_data
*data
);
2353 * The following inline functions are provided for convenience to simplify
2354 * event indication for some of the common events.
2357 static inline void drv_event_assoc(void *ctx
, const u8
*addr
, const u8
*ie
,
2360 union wpa_event_data event
;
2361 os_memset(&event
, 0, sizeof(event
));
2362 event
.assoc_info
.req_ies
= ie
;
2363 event
.assoc_info
.req_ies_len
= ielen
;
2364 event
.assoc_info
.addr
= addr
;
2365 wpa_supplicant_event(ctx
, EVENT_ASSOC
, &event
);
2368 static inline void drv_event_disassoc(void *ctx
, const u8
*addr
)
2370 union wpa_event_data event
;
2371 os_memset(&event
, 0, sizeof(event
));
2372 event
.disassoc_info
.addr
= addr
;
2373 wpa_supplicant_event(ctx
, EVENT_DISASSOC
, &event
);
2376 static inline void drv_event_eapol_rx(void *ctx
, const u8
*src
, const u8
*data
,
2379 union wpa_event_data event
;
2380 os_memset(&event
, 0, sizeof(event
));
2381 event
.eapol_rx
.src
= src
;
2382 event
.eapol_rx
.data
= data
;
2383 event
.eapol_rx
.data_len
= data_len
;
2384 wpa_supplicant_event(ctx
, EVENT_EAPOL_RX
, &event
);
2387 #endif /* DRIVER_H */