Nuke unnecessary setting of ural(4)'s security registers. ural(4) only
[dragonfly/vkernel-mp.git] / contrib / wpa_supplicant-0.4.9 / driver.h
blob9864e9b8ae3cbf5087db90c37c9aeed60e8b3245
1 /*
2 * WPA Supplicant - driver interface definition
3 * Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.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
10 * license.
12 * See README and COPYING for more details.
15 #ifndef DRIVER_H
16 #define DRIVER_H
18 #define WPA_SUPPLICANT_DRIVER_VERSION 2
20 #include "defs.h"
22 #define AUTH_ALG_OPEN_SYSTEM 0x01
23 #define AUTH_ALG_SHARED_KEY 0x02
24 #define AUTH_ALG_LEAP 0x04
26 #define IEEE80211_MODE_INFRA 0
27 #define IEEE80211_MODE_IBSS 1
29 #define IEEE80211_CAP_ESS 0x0001
30 #define IEEE80211_CAP_IBSS 0x0002
31 #define IEEE80211_CAP_PRIVACY 0x0010
33 #define SSID_MAX_WPA_IE_LEN 40
34 /**
35 * struct wpa_scan_result - Scan results
36 * @bssid: BSSID
37 * @ssid: SSID
38 * @ssid_len: length of the ssid
39 * @wpa_ie: WPA IE
40 * @wpa_ie_len: length of the wpa_ie
41 * @rsn_ie: RSN IE
42 * @rsn_ie_len: length of the RSN IE
43 * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
44 * @caps: capability information field in host byte order
45 * @qual: signal quality
46 * @noise: noise level
47 * @level: signal level
48 * @maxrate: maximum supported rate
50 * This structure is used as a generic format for scan results from the
51 * driver. Each driver interface implementation is responsible for converting
52 * the driver or OS specific scan results into this format.
54 struct wpa_scan_result {
55 u8 bssid[ETH_ALEN];
56 u8 ssid[32];
57 size_t ssid_len;
58 u8 wpa_ie[SSID_MAX_WPA_IE_LEN];
59 size_t wpa_ie_len;
60 u8 rsn_ie[SSID_MAX_WPA_IE_LEN];
61 size_t rsn_ie_len;
62 int freq;
63 u16 caps;
64 int qual;
65 int noise;
66 int level;
67 int maxrate;
70 /**
71 * struct wpa_driver_associate_params - Association parameters
72 * Data for struct wpa_driver_ops::associate().
74 struct wpa_driver_associate_params {
75 /**
76 * bssid - BSSID of the selected AP
77 * This can be %NULL, if ap_scan=2 mode is used and the driver is
78 * responsible for selecting with which BSS to associate. */
79 const u8 *bssid;
81 /**
82 * ssid - The selected SSID
84 const u8 *ssid;
85 size_t ssid_len;
87 /**
88 * freq - Frequency of the channel the selected AP is using
89 * Frequency that the selected AP is using (in MHz as
90 * reported in the scan results)
92 int freq;
94 /**
95 * wpa_ie - WPA information element for (Re)Association Request
96 * WPA information element to be included in (Re)Association
97 * Request (including information element id and length). Use
98 * of this WPA IE is optional. If the driver generates the WPA
99 * IE, it can use pairwise_suite, group_suite, and
100 * key_mgmt_suite to select proper algorithms. In this case,
101 * the driver has to notify wpa_supplicant about the used WPA
102 * IE by generating an event that the interface code will
103 * convert into EVENT_ASSOCINFO data (see wpa_supplicant.h).
104 * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
105 * instead. The driver can determine which version is used by
106 * looking at the first byte of the IE (0xdd for WPA, 0x30 for
107 * WPA2/RSN).
109 const u8 *wpa_ie;
111 * wpa_ie_len - length of the wpa_ie
113 size_t wpa_ie_len;
115 /* The selected pairwise/group cipher and key management
116 * suites. These are usually ignored if @wpa_ie is used. */
117 wpa_cipher pairwise_suite;
118 wpa_cipher group_suite;
119 wpa_key_mgmt key_mgmt_suite;
122 * auth_alg - Allowed authentication algorithms
123 * Bit field of AUTH_ALG_*
125 int auth_alg;
128 * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
130 int mode;
134 * struct wpa_driver_capa - Driver capability information
136 struct wpa_driver_capa {
137 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
138 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
139 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK 0x00000004
140 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK 0x00000008
141 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE 0x00000010
142 unsigned int key_mgmt;
144 #define WPA_DRIVER_CAPA_ENC_WEP40 0x00000001
145 #define WPA_DRIVER_CAPA_ENC_WEP104 0x00000002
146 #define WPA_DRIVER_CAPA_ENC_TKIP 0x00000004
147 #define WPA_DRIVER_CAPA_ENC_CCMP 0x00000008
148 unsigned int enc;
150 #define WPA_DRIVER_AUTH_OPEN 0x00000001
151 #define WPA_DRIVER_AUTH_SHARED 0x00000002
152 #define WPA_DRIVER_AUTH_LEAP 0x00000004
153 unsigned int auth;
155 /* Driver generated WPA/RSN IE */
156 #define WPA_DRIVER_FLAGS_DRIVER_IE 0x00000001
157 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
158 unsigned int flags;
163 * struct wpa_driver_ops - Driver interface API definition
165 * This structure defines the API that each driver interface needs to implement
166 * for core wpa_supplicant code. All driver specific functionality is captured
167 * in this wrapper.
169 struct wpa_driver_ops {
170 /** Name of the driver interface */
171 const char *name;
172 /** One line description of the driver interface */
173 const char *desc;
176 * get_bssid - Get the current BSSID
177 * @priv: private driver interface data
178 * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
180 * Returns: 0 on success, -1 on failure
182 * Query kernel driver for the current BSSID and copy it to bssid.
183 * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
184 * associated.
186 int (*get_bssid)(void *priv, u8 *bssid);
189 * get_ssid - Get the current SSID
190 * @priv: private driver interface data
191 * @ssid: buffer for SSID (at least 32 bytes)
193 * Returns: Length of the SSID on success, -1 on failure
195 * Query kernel driver for the current SSID and copy it to ssid.
196 * Returning zero is recommended if the STA is not associated.
198 * Note: SSID is an array of octets, i.e., it is not nul terminated and
199 * can, at least in theory, contain control characters (including nul)
200 * and as such, should be processed as binary data, not a printable
201 * string.
203 int (*get_ssid)(void *priv, u8 *ssid);
206 * set_wpa - Enable/disable WPA support (OBSOLETE)
207 * @priv: private driver interface data
208 * @enabled: 1 = enable, 0 = disable
210 * Returns: 0 on success, -1 on failure
212 * Note: This function is included for backwards compatibility. This is
213 * called only just after init and just before deinit, so these
214 * functions can be used to implement same functionality and the driver
215 * interface need not define this function.
217 * Configure the kernel driver to enable/disable WPA support. This may
218 * be empty function, if WPA support is always enabled. Common
219 * configuration items are WPA IE (clearing it when WPA support is
220 * disabled), Privacy flag configuration for capability field (note:
221 * this the value need to set in associate handler to allow plaintext
222 * mode to be used) when trying to associate with, roaming mode (can
223 * allow wpa_supplicant to control roaming if ap_scan=1 is used;
224 * however, drivers can also implement roaming if desired, especially
225 * ap_scan=2 mode is used for this).
227 int (*set_wpa)(void *priv, int enabled);
230 * set_key - Configure encryption key
231 * @priv: private driver interface data
232 * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
233 * %WPA_ALG_TKIP, %WPA_ALG_CCMP); %WPA_ALG_NONE clears the key.
234 * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
235 * broadcast/default keys
236 * @key_idx: key index (0..3), usually 0 for unicast keys
237 * @set_tx: configure this key as the default Tx key (only used when
238 * driver does not support separate unicast/individual key
239 * @seq: sequence number/packet number, seq_len octets, the next
240 * packet number to be used for in replay protection; configured
241 * for Rx keys (in most cases, this is only used with broadcast
242 * keys and set to zero for unicast keys)
243 * @seq_len: length of the seq, depends on the algorithm:
244 * TKIP: 6 octets, CCMP: 6 octets
245 * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
246 * 8-byte Rx Mic Key
247 * @key_len: length of the key buffer in octets (WEP: 5 or 13,
248 * TKIP: 32, CCMP: 16)
250 * Returns: 0 on success, -1 on failure
252 * Configure the given key for the kernel driver. If the driver
253 * supports separate individual keys (4 default keys + 1 individual),
254 * addr can be used to determine whether the key is default or
255 * individual. If only 4 keys are supported, the default key with key
256 * index 0 is used as the individual key. STA must be configured to use
257 * it as the default Tx key (set_tx is set) and accept Rx for all the
258 * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
259 * broadcast keys, so key index 0 is available for this kind of
260 * configuration.
262 * Please note that TKIP keys include separate TX and RX MIC keys and
263 * some drivers may expect them in different order than wpa_supplicant
264 * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
265 * will tricker Michael MIC errors. This can be fixed by changing the
266 * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
267 * in driver_*.c set_key() implementation, see driver_ndis.c for an
268 * example on how this can be done.
270 int (*set_key)(void *priv, wpa_alg alg, const u8 *addr,
271 int key_idx, int set_tx, const u8 *seq, size_t seq_len,
272 const u8 *key, size_t key_len);
275 * init - Initialize driver interface
276 * @ctx: context to be used when calling wpa_supplicant functions,
277 * e.g., wpa_supplicant_event()
278 * @ifname: interface name, e.g., wlan0
280 * Returns: Pointer to private data, %NULL on failure
282 * Initialize driver interface, including event processing for kernel
283 * driver events (e.g., associated, scan results, Michael MIC failure).
284 * This function can allocate a private configuration data area for
285 * @ctx, file descriptor, interface name, etc. information that may be
286 * needed in future driver operations. If this is not used, non-NULL
287 * value will need to be returned because %NULL is used to indicate
288 * failure. The returned value will be used as 'void *priv' data for
289 * all other driver_ops functions.
291 * The main event loop (eloop.c) of wpa_supplicant can be used to
292 * register callback for read sockets (eloop_register_read_sock()).
294 * See wpa_supplicant.h for more information about events and
295 * wpa_supplicant_event() function.
297 void * (*init)(void *ctx, const char *ifname);
300 * deinit - Deinitialize driver interface
301 * @priv: private driver interface data from init()
303 * Shut down driver interface and processing of driver events. Free
304 * private data buffer if one was allocated in init() handler.
306 void (*deinit)(void *priv);
309 * set_param - Set driver configuration parameters
310 * @priv: private driver interface data from init()
311 * @param: driver specific configuration parameters
313 * Returns: 0 on success, -1 on failure
315 * Optional handler for notifying driver interface about configuration
316 * parameters (driver_param).
318 int (*set_param)(void *priv, const char *param);
321 * set_countermeasures - Enable/disable TKIP countermeasures
322 * @priv: private driver interface data
323 * @enabled: 1 = countermeasures enabled, 0 = disabled
325 * Returns: 0 on success, -1 on failure
327 * Configure TKIP countermeasures. When these are enabled, the driver
328 * should drop all received and queued frames that are using TKIP.
330 int (*set_countermeasures)(void *priv, int enabled);
333 * set_drop_unencrypted - Enable/disable unencrypted frame filtering
334 * @priv: private driver interface data
335 * @enabled: 1 = unencrypted Tx/Rx frames will be dropped, 0 = disabled
337 * Returns: 0 on success, -1 on failure
339 * Configure the driver to drop all non-EAPOL frames (both receive and
340 * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
341 * still be allowed for key negotiation.
343 int (*set_drop_unencrypted)(void *priv, int enabled);
346 * scan - Request the driver to initiate scan
347 * @priv: private driver interface data
348 * @ssid: specific SSID to scan for (ProbeReq) or %NULL to scan for
349 * all SSIDs (either active scan with broadcast SSID or passive
350 * scan
351 * @ssid_len: length of the SSID
353 * Returns: 0 on success, -1 on failure
355 * Once the scan results are ready, the driver should report scan
356 * results event for wpa_supplicant which will eventually request the
357 * results with wpa_driver_get_scan_results().
359 int (*scan)(void *priv, const u8 *ssid, size_t ssid_len);
362 * get_scan_results - Fetch the latest scan results
363 * @priv: private driver interface data
364 * @results: pointer to buffer for scan results
365 * @max_size: maximum number of entries (buffer size)
367 * Returns: Number of scan result entries used on success, -1 on
368 * failure
370 * If scan results include more than max_size BSSes, max_size will be
371 * returned and the remaining entries will not be included in the
372 * buffer.
374 int (*get_scan_results)(void *priv,
375 struct wpa_scan_result *results,
376 size_t max_size);
379 * deauthenticate - Request driver to deauthenticate
380 * @priv: private driver interface data
381 * @addr: peer address (BSSID of the AP)
382 * @reason_code: 16-bit reason code to be sent in the deauthentication
383 * frame
385 * Returns: 0 on success, -1 on failure
387 int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
390 * disassociate - Request driver to disassociate
391 * @priv: private driver interface data
392 * @addr: peer address (BSSID of the AP)
393 * @reason_code: 16-bit reason code to be sent in the disassociation
394 * frame
396 * Returns: 0 on success, -1 on failure
398 int (*disassociate)(void *priv, const u8 *addr, int reason_code);
401 * associate - Request driver to associate
402 * @priv: private driver interface data
403 * @params: association parameters
405 * Returns: 0 on success, -1 on failure
407 int (*associate)(void *priv,
408 struct wpa_driver_associate_params *params);
411 * set_auth_alg - Set IEEE 802.11 authentication algorithm
412 * @priv: private driver interface data
413 * @auth_alg: bit field of AUTH_ALG_*
415 * If the driver supports more than one authentication algorithm at the
416 * same time, it should configure all supported algorithms. If not, one
417 * algorithm needs to be selected arbitrarily. Open System
418 * authentication should be ok for most cases and it is recommended to
419 * be used if other options are not supported. Static WEP configuration
420 * may also use Shared Key authentication and LEAP requires its own
421 * algorithm number. For LEAP, user can make sure that only one
422 * algorithm is used at a time by configuring LEAP as the only
423 * supported EAP method. This information is also available in
424 * associate() params, so set_auth_alg may not be needed in case of
425 * most drivers.
427 * Returns: 0 on success, -1 on failure
429 int (*set_auth_alg)(void *priv, int auth_alg);
432 * add_pmkid - Add PMKSA cache entry to the driver
433 * @priv: private driver interface data
434 * @bssid: BSSID for the PMKSA cache entry
435 * @pmkid: PMKID for the PMKSA cache entry
437 * Returns: 0 on success, -1 on failure
439 * This function is called when a new PMK is received, as a result of
440 * either normal authentication or RSN pre-authentication.
442 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
443 * associate(), add_pmkid() can be used to add new PMKSA cache entries
444 * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
445 * driver_ops function does not need to be implemented. Likewise, if
446 * the driver does not support WPA, this function is not needed.
448 int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
451 * remove_pmkid - Remove PMKSA cache entry to the driver
452 * @priv: private driver interface data
453 * @bssid: BSSID for the PMKSA cache entry
454 * @pmkid: PMKID for the PMKSA cache entry
456 * Returns: 0 on success, -1 on failure
458 * This function is called when the supplicant drops a PMKSA cache
459 * entry for any reason.
461 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
462 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
463 * between the driver and wpa_supplicant. If the driver uses wpa_ie
464 * from wpa_supplicant, this driver_ops function does not need to be
465 * implemented. Likewise, if the driver does not support WPA, this
466 * function is not needed.
468 int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
471 * flush_pmkid - Flush PMKSA cache
472 * @priv: private driver interface data
474 * Returns: 0 on success, -1 on failure
476 * This function is called when the supplicant drops all PMKSA cache
477 * entries for any reason.
479 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
480 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
481 * between the driver and wpa_supplicant. If the driver uses wpa_ie
482 * from wpa_supplicant, this driver_ops function does not need to be
483 * implemented. Likewise, if the driver does not support WPA, this
484 * function is not needed.
486 int (*flush_pmkid)(void *priv);
489 * flush_pmkid - Flush PMKSA cache
490 * @priv: private driver interface data
492 * Returns: 0 on success, -1 on failure
494 * Get driver/firmware/hardware capabilities.
496 int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
499 * poll - Poll driver for association information
500 * @priv: private driver interface data
502 * This is an option callback that can be used when the driver does not
503 * provide event mechanism for association events. This is called when
504 * receiving WPA EAPOL-Key messages that require association
505 * information. The driver interface is supposed to generate associnfo
506 * event before returning from this callback function. In addition, the
507 * driver interface should generate an association event after having
508 * sent out associnfo.
510 void (*poll)(void *priv);
513 * get_ifname - Get interface name
514 * @priv: private driver interface data
516 * Returns: Pointer to the interface name. This can differ from the
517 * interface name used in init() call.
519 * This optional function can be used to allow the driver interface to
520 * replace the interface name with something else, e.g., based on an
521 * interface mapping from a more descriptive name.
523 const char * (*get_ifname)(void *priv);
526 * get_mac_addr - Get own MAC address
527 * @priv: private driver interface data
529 * Returns: Pointer to own MAC address or %NULL on failure
531 * This optional function can be used to get the own MAC address of the
532 * device from the driver interface code. This is only needed if the
533 * l2_packet implementation for the OS does not provide easy access to
534 * a MAC address. */
535 const u8 * (*get_mac_addr)(void *priv);
538 * send_eapol - Optional function for sending EAPOL packets
539 * @priv: private driver interface data
540 * @dest: Destination MAC address
541 * @proto: Ethertype
542 * @data: EAPOL packet starting with IEEE 802.1X header
543 * @data_len: Size of the EAPOL packet
545 * Returns: 0 on success, -1 on failure
547 * This optional function can be used to override l2_packet operations
548 * with driver specific functionality. If this function pointer is set,
549 * l2_packet module is not used at all and the driver interface code is
550 * responsible for receiving and sending all EAPOL packets. The
551 * received EAPOL packets are sent to core code by calling
552 * wpa_supplicant_rx_eapol(). The driver interface is required to
553 * implement get_mac_addr() handler if send_eapol() is used.
555 int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
556 const u8 *data, size_t data_len);
559 #endif /* DRIVER_H */