summaryrefslogtreecommitdiffstats
path: root/contrib/wpa_supplicant/driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/wpa_supplicant/driver.h')
-rw-r--r--contrib/wpa_supplicant/driver.h281
1 files changed, 202 insertions, 79 deletions
diff --git a/contrib/wpa_supplicant/driver.h b/contrib/wpa_supplicant/driver.h
index da28014..9864e9b 100644
--- a/contrib/wpa_supplicant/driver.h
+++ b/contrib/wpa_supplicant/driver.h
@@ -1,13 +1,23 @@
+/*
+ * WPA Supplicant - driver interface definition
+ * Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
#ifndef DRIVER_H
#define DRIVER_H
#define WPA_SUPPLICANT_DRIVER_VERSION 2
-typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg;
-typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
- CIPHER_WEP104 } wpa_cipher;
-typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
- KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt;
+#include "defs.h"
#define AUTH_ALG_OPEN_SYSTEM 0x01
#define AUTH_ALG_SHARED_KEY 0x02
@@ -16,7 +26,31 @@ typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
#define IEEE80211_MODE_INFRA 0
#define IEEE80211_MODE_IBSS 1
+#define IEEE80211_CAP_ESS 0x0001
+#define IEEE80211_CAP_IBSS 0x0002
+#define IEEE80211_CAP_PRIVACY 0x0010
+
#define SSID_MAX_WPA_IE_LEN 40
+/**
+ * struct wpa_scan_result - Scan results
+ * @bssid: BSSID
+ * @ssid: SSID
+ * @ssid_len: length of the ssid
+ * @wpa_ie: WPA IE
+ * @wpa_ie_len: length of the wpa_ie
+ * @rsn_ie: RSN IE
+ * @rsn_ie_len: length of the RSN IE
+ * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
+ * @caps: capability information field in host byte order
+ * @qual: signal quality
+ * @noise: noise level
+ * @level: signal level
+ * @maxrate: maximum supported rate
+ *
+ * This structure is used as a generic format for scan results from the
+ * driver. Each driver interface implementation is responsible for converting
+ * the driver or OS specific scan results into this format.
+ */
struct wpa_scan_result {
u8 bssid[ETH_ALEN];
u8 ssid[32];
@@ -25,40 +59,57 @@ struct wpa_scan_result {
size_t wpa_ie_len;
u8 rsn_ie[SSID_MAX_WPA_IE_LEN];
size_t rsn_ie_len;
- int freq; /* MHz */
- int caps; /* e.g. privacy */
- int qual; /* signal quality */
+ int freq;
+ u16 caps;
+ int qual;
int noise;
int level;
int maxrate;
};
-/* Parameters for associate driver_ops. */
+/**
+ * struct wpa_driver_associate_params - Association parameters
+ * Data for struct wpa_driver_ops::associate().
+ */
struct wpa_driver_associate_params {
- /* BSSID of the selected AP */
+ /**
+ * bssid - BSSID of the selected AP
+ * This can be %NULL, if ap_scan=2 mode is used and the driver is
+ * responsible for selecting with which BSS to associate. */
const u8 *bssid;
- /* The selected SSID and its length in bytes */
+ /**
+ * ssid - The selected SSID
+ */
const u8 *ssid;
size_t ssid_len;
- /* frequency that the selected AP is using (in MHz as
- * reported in the scan results) */
+ /**
+ * freq - Frequency of the channel the selected AP is using
+ * Frequency that the selected AP is using (in MHz as
+ * reported in the scan results)
+ */
int freq;
- /* WPA information element to be included in (Re)Association
+ /**
+ * wpa_ie - WPA information element for (Re)Association Request
+ * WPA information element to be included in (Re)Association
* Request (including information element id and length). Use
* of this WPA IE is optional. If the driver generates the WPA
- * IE, it can use @pairwise_suite, @group_suite, and
- * @key_mgmt_suite to select proper algorithms. In this case,
+ * IE, it can use pairwise_suite, group_suite, and
+ * key_mgmt_suite to select proper algorithms. In this case,
* the driver has to notify wpa_supplicant about the used WPA
* IE by generating an event that the interface code will
* convert into EVENT_ASSOCINFO data (see wpa_supplicant.h).
- * When using WPA2/IEEE 802.11i, @wpa_ie is used for RSN IE
+ * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
* instead. The driver can determine which version is used by
* looking at the first byte of the IE (0xdd for WPA, 0x30 for
- * WPA2/RSN). @wpa_ie_len: length of the @wpa_ie */
+ * WPA2/RSN).
+ */
const u8 *wpa_ie;
+ /**
+ * wpa_ie_len - length of the wpa_ie
+ */
size_t wpa_ie_len;
/* The selected pairwise/group cipher and key management
@@ -67,10 +118,21 @@ struct wpa_driver_associate_params {
wpa_cipher group_suite;
wpa_key_mgmt key_mgmt_suite;
- int auth_alg; /* bit field of AUTH_ALG_* */
- int mode; /* IEEE80211_MODE_* */
+ /**
+ * auth_alg - Allowed authentication algorithms
+ * Bit field of AUTH_ALG_*
+ */
+ int auth_alg;
+
+ /**
+ * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
+ */
+ int mode;
};
+/**
+ * struct wpa_driver_capa - Driver capability information
+ */
struct wpa_driver_capa {
#define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
#define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
@@ -97,33 +159,40 @@ struct wpa_driver_capa {
};
+/**
+ * struct wpa_driver_ops - Driver interface API definition
+ *
+ * This structure defines the API that each driver interface needs to implement
+ * for core wpa_supplicant code. All driver specific functionality is captured
+ * in this wrapper.
+ */
struct wpa_driver_ops {
- /* name of the driver interface */
+ /** Name of the driver interface */
const char *name;
- /* one line description of the driver interface */
+ /** One line description of the driver interface */
const char *desc;
/**
- * get_bssid - get the current BSSID
+ * get_bssid - Get the current BSSID
* @priv: private driver interface data
* @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
*
* Returns: 0 on success, -1 on failure
*
- * Query kernel driver for the current BSSID and copy it to @bssid.
- * Setting @bssid to 00:00:00:00:00:00 is recommended if the STA is not
+ * Query kernel driver for the current BSSID and copy it to bssid.
+ * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
* associated.
*/
int (*get_bssid)(void *priv, u8 *bssid);
/**
- * get_ssid - get the current SSID
+ * get_ssid - Get the current SSID
* @priv: private driver interface data
* @ssid: buffer for SSID (at least 32 bytes)
*
- * Returns: length of the SSID on success, -1 on failure
+ * Returns: Length of the SSID on success, -1 on failure
*
- * Query kernel driver for the current SSID and copy it to @ssid.
+ * Query kernel driver for the current SSID and copy it to ssid.
* Returning zero is recommended if the STA is not associated.
*
* Note: SSID is an array of octets, i.e., it is not nul terminated and
@@ -134,35 +203,44 @@ struct wpa_driver_ops {
int (*get_ssid)(void *priv, u8 *ssid);
/**
- * set_wpa - enable/disable WPA support
+ * set_wpa - Enable/disable WPA support (OBSOLETE)
* @priv: private driver interface data
* @enabled: 1 = enable, 0 = disable
*
* Returns: 0 on success, -1 on failure
*
+ * Note: This function is included for backwards compatibility. This is
+ * called only just after init and just before deinit, so these
+ * functions can be used to implement same functionality and the driver
+ * interface need not define this function.
+ *
* Configure the kernel driver to enable/disable WPA support. This may
* be empty function, if WPA support is always enabled. Common
* configuration items are WPA IE (clearing it when WPA support is
- * disabled), Privacy flag for capability field, roaming mode (need to
- * allow wpa_supplicant to control roaming).
+ * disabled), Privacy flag configuration for capability field (note:
+ * this the value need to set in associate handler to allow plaintext
+ * mode to be used) when trying to associate with, roaming mode (can
+ * allow wpa_supplicant to control roaming if ap_scan=1 is used;
+ * however, drivers can also implement roaming if desired, especially
+ * ap_scan=2 mode is used for this).
*/
int (*set_wpa)(void *priv, int enabled);
/**
- * set_key - configure encryption key
+ * set_key - Configure encryption key
* @priv: private driver interface data
* @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
* %WPA_ALG_TKIP, %WPA_ALG_CCMP); %WPA_ALG_NONE clears the key.
* @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
* broadcast/default keys
- * @key_idx: key index (0..3), always 0 for unicast keys
+ * @key_idx: key index (0..3), usually 0 for unicast keys
* @set_tx: configure this key as the default Tx key (only used when
* driver does not support separate unicast/individual key
- * @seq: sequence number/packet number, @seq_len octets, the next
+ * @seq: sequence number/packet number, seq_len octets, the next
* packet number to be used for in replay protection; configured
* for Rx keys (in most cases, this is only used with broadcast
* keys and set to zero for unicast keys)
- * @seq_len: length of the @seq, depends on the algorithm:
+ * @seq_len: length of the seq, depends on the algorithm:
* TKIP: 6 octets, CCMP: 6 octets
* @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
* 8-byte Rx Mic Key
@@ -173,25 +251,33 @@ struct wpa_driver_ops {
*
* Configure the given key for the kernel driver. If the driver
* supports separate individual keys (4 default keys + 1 individual),
- * @addr can be used to determine whether the key is default or
+ * addr can be used to determine whether the key is default or
* individual. If only 4 keys are supported, the default key with key
* index 0 is used as the individual key. STA must be configured to use
- * it as the default Tx key (@set_tx is set) and accept Rx for all the
+ * it as the default Tx key (set_tx is set) and accept Rx for all the
* key indexes. In most cases, WPA uses only key indexes 1 and 2 for
* broadcast keys, so key index 0 is available for this kind of
* configuration.
+ *
+ * Please note that TKIP keys include separate TX and RX MIC keys and
+ * some drivers may expect them in different order than wpa_supplicant
+ * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
+ * will tricker Michael MIC errors. This can be fixed by changing the
+ * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
+ * in driver_*.c set_key() implementation, see driver_ndis.c for an
+ * example on how this can be done.
*/
int (*set_key)(void *priv, wpa_alg alg, const u8 *addr,
int key_idx, int set_tx, const u8 *seq, size_t seq_len,
const u8 *key, size_t key_len);
/**
- * init - initialize driver interface
+ * init - Initialize driver interface
* @ctx: context to be used when calling wpa_supplicant functions,
* e.g., wpa_supplicant_event()
* @ifname: interface name, e.g., wlan0
*
- * Return: pointer to private data, %NULL on failure
+ * Returns: Pointer to private data, %NULL on failure
*
* Initialize driver interface, including event processing for kernel
* driver events (e.g., associated, scan results, Michael MIC failure).
@@ -211,9 +297,8 @@ struct wpa_driver_ops {
void * (*init)(void *ctx, const char *ifname);
/**
- * deinit - deinitialize driver interface
- * @priv: pointer to private data (from matching
- * wpa_driver_events_init())
+ * deinit - Deinitialize driver interface
+ * @priv: private driver interface data from init()
*
* Shut down driver interface and processing of driver events. Free
* private data buffer if one was allocated in init() handler.
@@ -221,11 +306,23 @@ struct wpa_driver_ops {
void (*deinit)(void *priv);
/**
- * set_countermeasures - enable/disable TKIP countermeasures
+ * set_param - Set driver configuration parameters
+ * @priv: private driver interface data from init()
+ * @param: driver specific configuration parameters
+ *
+ * Returns: 0 on success, -1 on failure
+ *
+ * Optional handler for notifying driver interface about configuration
+ * parameters (driver_param).
+ */
+ int (*set_param)(void *priv, const char *param);
+
+ /**
+ * set_countermeasures - Enable/disable TKIP countermeasures
* @priv: private driver interface data
* @enabled: 1 = countermeasures enabled, 0 = disabled
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* Configure TKIP countermeasures. When these are enabled, the driver
* should drop all received and queued frames that are using TKIP.
@@ -233,11 +330,11 @@ struct wpa_driver_ops {
int (*set_countermeasures)(void *priv, int enabled);
/**
- * set_drop_unencrypted - enable/disable unencrypted frame filtering
+ * set_drop_unencrypted - Enable/disable unencrypted frame filtering
* @priv: private driver interface data
* @enabled: 1 = unencrypted Tx/Rx frames will be dropped, 0 = disabled
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* Configure the driver to drop all non-EAPOL frames (both receive and
* transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
@@ -246,14 +343,14 @@ struct wpa_driver_ops {
int (*set_drop_unencrypted)(void *priv, int enabled);
/**
- * scan - request the driver to initiate scan
+ * scan - Request the driver to initiate scan
* @priv: private driver interface data
* @ssid: specific SSID to scan for (ProbeReq) or %NULL to scan for
* all SSIDs (either active scan with broadcast SSID or passive
* scan
* @ssid_len: length of the SSID
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* Once the scan results are ready, the driver should report scan
* results event for wpa_supplicant which will eventually request the
@@ -262,14 +359,15 @@ struct wpa_driver_ops {
int (*scan)(void *priv, const u8 *ssid, size_t ssid_len);
/**
- * get_scan_results - fetch the latest scan results
+ * get_scan_results - Fetch the latest scan results
* @priv: private driver interface data
* @results: pointer to buffer for scan results
* @max_size: maximum number of entries (buffer size)
*
- * Return: number of scan result entries used on success, -1 on failure
+ * Returns: Number of scan result entries used on success, -1 on
+ * failure
*
- * If scan results include more than @max_size BSSes, @max_size will be
+ * If scan results include more than max_size BSSes, max_size will be
* returned and the remaining entries will not be included in the
* buffer.
*/
@@ -278,39 +376,39 @@ struct wpa_driver_ops {
size_t max_size);
/**
- * deauthenticate - request driver to deauthenticate
+ * deauthenticate - Request driver to deauthenticate
* @priv: private driver interface data
* @addr: peer address (BSSID of the AP)
* @reason_code: 16-bit reason code to be sent in the deauthentication
* frame
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*/
int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
/**
- * disassociate - request driver to disassociate
+ * disassociate - Request driver to disassociate
* @priv: private driver interface data
* @addr: peer address (BSSID of the AP)
* @reason_code: 16-bit reason code to be sent in the disassociation
* frame
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*/
int (*disassociate)(void *priv, const u8 *addr, int reason_code);
/**
- * associate - request driver to associate
+ * associate - Request driver to associate
* @priv: private driver interface data
* @params: association parameters
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*/
int (*associate)(void *priv,
struct wpa_driver_associate_params *params);
/**
- * set_auth_alg - set IEEE 802.11 authentication algorithm
+ * set_auth_alg - Set IEEE 802.11 authentication algorithm
* @priv: private driver interface data
* @auth_alg: bit field of AUTH_ALG_*
*
@@ -326,43 +424,43 @@ struct wpa_driver_ops {
* associate() params, so set_auth_alg may not be needed in case of
* most drivers.
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*/
int (*set_auth_alg)(void *priv, int auth_alg);
/**
- * add_pmkid - add PMKSA cache entry to the driver
+ * add_pmkid - Add PMKSA cache entry to the driver
* @priv: private driver interface data
* @bssid: BSSID for the PMKSA cache entry
* @pmkid: PMKID for the PMKSA cache entry
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* This function is called when a new PMK is received, as a result of
* either normal authentication or RSN pre-authentication.
*
- * If the driver generates RSN IE, i.e., it does not use @wpa_ie in
+ * If the driver generates RSN IE, i.e., it does not use wpa_ie in
* associate(), add_pmkid() can be used to add new PMKSA cache entries
- * in the driver. If the driver uses @wpa_ie from wpa_supplicant, this
+ * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
* driver_ops function does not need to be implemented. Likewise, if
* the driver does not support WPA, this function is not needed.
*/
int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
/**
- * remove_pmkid - remove PMKSA cache entry to the driver
+ * remove_pmkid - Remove PMKSA cache entry to the driver
* @priv: private driver interface data
* @bssid: BSSID for the PMKSA cache entry
* @pmkid: PMKID for the PMKSA cache entry
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* This function is called when the supplicant drops a PMKSA cache
* entry for any reason.
*
- * If the driver generates RSN IE, i.e., it does not use @wpa_ie in
+ * If the driver generates RSN IE, i.e., it does not use wpa_ie in
* associate(), remove_pmkid() can be used to synchronize PMKSA caches
- * between the driver and wpa_supplicant. If the driver uses @wpa_ie
+ * between the driver and wpa_supplicant. If the driver uses wpa_ie
* from wpa_supplicant, this driver_ops function does not need to be
* implemented. Likewise, if the driver does not support WPA, this
* function is not needed.
@@ -370,17 +468,17 @@ struct wpa_driver_ops {
int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
/**
- * flush_pmkid - flush PMKSA cache
+ * flush_pmkid - Flush PMKSA cache
* @priv: private driver interface data
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* This function is called when the supplicant drops all PMKSA cache
* entries for any reason.
*
- * If the driver generates RSN IE, i.e., it does not use @wpa_ie in
+ * If the driver generates RSN IE, i.e., it does not use wpa_ie in
* associate(), remove_pmkid() can be used to synchronize PMKSA caches
- * between the driver and wpa_supplicant. If the driver uses @wpa_ie
+ * between the driver and wpa_supplicant. If the driver uses wpa_ie
* from wpa_supplicant, this driver_ops function does not need to be
* implemented. Likewise, if the driver does not support WPA, this
* function is not needed.
@@ -388,17 +486,17 @@ struct wpa_driver_ops {
int (*flush_pmkid)(void *priv);
/**
- * flush_pmkid - flush PMKSA cache
+ * flush_pmkid - Flush PMKSA cache
* @priv: private driver interface data
*
- * Return: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure
*
* Get driver/firmware/hardware capabilities.
*/
int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
/**
- * poll - poll driver for association information
+ * poll - Poll driver for association information
* @priv: private driver interface data
*
* This is an option callback that can be used when the driver does not
@@ -412,25 +510,50 @@ struct wpa_driver_ops {
void (*poll)(void *priv);
/**
- * get_ifname - get interface name
+ * get_ifname - Get interface name
+ * @priv: private driver interface data
+ *
+ * Returns: Pointer to the interface name. This can differ from the
+ * interface name used in init() call.
*
* This optional function can be used to allow the driver interface to
* replace the interface name with something else, e.g., based on an
* interface mapping from a more descriptive name.
- *
- * Returns a pointer to the interface name. This can differ from the
- * interface name used in init() call.
*/
const char * (*get_ifname)(void *priv);
/**
- * get_mac_addr - get own MAC address
+ * get_mac_addr - Get own MAC address
+ * @priv: private driver interface data
+ *
+ * Returns: Pointer to own MAC address or %NULL on failure
*
* This optional function can be used to get the own MAC address of the
* device from the driver interface code. This is only needed if the
* l2_packet implementation for the OS does not provide easy access to
* a MAC address. */
const u8 * (*get_mac_addr)(void *priv);
+
+ /**
+ * send_eapol - Optional function for sending EAPOL packets
+ * @priv: private driver interface data
+ * @dest: Destination MAC address
+ * @proto: Ethertype
+ * @data: EAPOL packet starting with IEEE 802.1X header
+ * @data_len: Size of the EAPOL packet
+ *
+ * Returns: 0 on success, -1 on failure
+ *
+ * This optional function can be used to override l2_packet operations
+ * with driver specific functionality. If this function pointer is set,
+ * l2_packet module is not used at all and the driver interface code is
+ * responsible for receiving and sending all EAPOL packets. The
+ * received EAPOL packets are sent to core code by calling
+ * wpa_supplicant_rx_eapol(). The driver interface is required to
+ * implement get_mac_addr() handler if send_eapol() is used.
+ */
+ int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
+ const u8 *data, size_t data_len);
};
#endif /* DRIVER_H */
OpenPOWER on IntegriCloud