• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * WPA Supplicant - driver interface definition
3  * Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14 
15 #ifndef DRIVER_H
16 #define DRIVER_H
17 
18 #define WPA_SUPPLICANT_DRIVER_VERSION 2
19 
20 #include "defs.h"
21 
22 #define AUTH_ALG_OPEN_SYSTEM	0x01
23 #define AUTH_ALG_SHARED_KEY	0x02
24 #define AUTH_ALG_LEAP		0x04
25 
26 #define IEEE80211_MODE_INFRA	0
27 #define IEEE80211_MODE_IBSS	1
28 
29 #define IEEE80211_CAP_ESS	0x0001
30 #define IEEE80211_CAP_IBSS	0x0002
31 #define IEEE80211_CAP_PRIVACY	0x0010
32 
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
49  *
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.
53  */
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;
68 };
69 
70 /**
71  * struct wpa_driver_associate_params - Association parameters
72  * Data for struct wpa_driver_ops::associate().
73  */
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;
80 
81 	/**
82 	 * ssid - The selected SSID
83 	 */
84 	const u8 *ssid;
85 	size_t ssid_len;
86 
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)
91 	 */
92 	int freq;
93 
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).
108 	 */
109 	const u8 *wpa_ie;
110 	/**
111 	 * wpa_ie_len - length of the wpa_ie
112 	 */
113 	size_t wpa_ie_len;
114 
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;
120 
121 	/**
122 	 * auth_alg - Allowed authentication algorithms
123 	 * Bit field of AUTH_ALG_*
124 	 */
125 	int auth_alg;
126 
127 	/**
128 	 * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
129 	 */
130 	int mode;
131 
132 	/**
133 	 * wep_key - WEP keys for static WEP configuration
134 	 */
135 	const u8 *wep_key[4];
136 
137 	/**
138 	 * wep_key_len - WEP key length for static WEP configuration
139 	 */
140 	size_t wep_key_len[4];
141 
142 	/**
143 	 * wep_tx_keyidx - WEP TX key index for static WEP configuration
144 	 */
145 	int wep_tx_keyidx;
146 
147 	/**
148 	 * mgmt_frame_protection - IEEE 802.11w management frame protection
149 	 */
150 	enum {
151 		NO_MGMT_FRAME_PROTECTION,
152 		MGMT_FRAME_PROTECTION_OPTIONAL,
153 		MGMT_FRAME_PROTECTION_REQUIRED
154 	} mgmt_frame_protection;
155 };
156 
157 /**
158  * struct wpa_driver_capa - Driver capability information
159  */
160 struct wpa_driver_capa {
161 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA		0x00000001
162 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2		0x00000002
163 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK	0x00000004
164 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK	0x00000008
165 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE	0x00000010
166 	unsigned int key_mgmt;
167 
168 #define WPA_DRIVER_CAPA_ENC_WEP40	0x00000001
169 #define WPA_DRIVER_CAPA_ENC_WEP104	0x00000002
170 #define WPA_DRIVER_CAPA_ENC_TKIP	0x00000004
171 #define WPA_DRIVER_CAPA_ENC_CCMP	0x00000008
172 	unsigned int enc;
173 
174 #define WPA_DRIVER_AUTH_OPEN		0x00000001
175 #define WPA_DRIVER_AUTH_SHARED		0x00000002
176 #define WPA_DRIVER_AUTH_LEAP		0x00000004
177 	unsigned int auth;
178 
179 /* Driver generated WPA/RSN IE */
180 #define WPA_DRIVER_FLAGS_DRIVER_IE	0x00000001
181 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
182 #define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
183 	unsigned int flags;
184 };
185 
186 
187 #define WPA_CHAN_W_SCAN 0x00000001
188 #define WPA_CHAN_W_ACTIVE_SCAN 0x00000002
189 #define WPA_CHAN_W_IBSS 0x00000004
190 
191 struct wpa_channel_data {
192 	short chan; /* channel number (IEEE 802.11) */
193 	short freq; /* frequency in MHz */
194 	int flag; /* flag for user space use (WPA_CHAN_*) */
195 };
196 
197 #define WPA_RATE_ERP 0x00000001
198 #define WPA_RATE_BASIC 0x00000002
199 #define WPA_RATE_PREAMBLE2 0x00000004
200 #define WPA_RATE_SUPPORTED 0x00000010
201 #define WPA_RATE_OFDM 0x00000020
202 #define WPA_RATE_CCK 0x00000040
203 #define WPA_RATE_MANDATORY 0x00000100
204 
205 struct wpa_rate_data {
206 	int rate; /* rate in 100 kbps */
207 	int flags; /* WPA_RATE_ flags */
208 };
209 
210 typedef enum {
211 	WPA_MODE_IEEE80211B,
212 	WPA_MODE_IEEE80211G,
213 	WPA_MODE_IEEE80211A,
214 	NUM_WPA_MODES
215 } wpa_hw_mode;
216 
217 struct wpa_hw_modes {
218 	wpa_hw_mode mode;
219 	int num_channels;
220 	struct wpa_channel_data *channels;
221 	int num_rates;
222 	struct wpa_rate_data *rates;
223 };
224 
225 
226 struct ieee80211_rx_status {
227         int channel;
228         int ssi;
229 };
230 
231 
232 /**
233  * struct wpa_driver_ops - Driver interface API definition
234  *
235  * This structure defines the API that each driver interface needs to implement
236  * for core wpa_supplicant code. All driver specific functionality is captured
237  * in this wrapper.
238  */
239 struct wpa_driver_ops {
240 	/** Name of the driver interface */
241 	const char *name;
242 	/** One line description of the driver interface */
243 	const char *desc;
244 
245 	/**
246 	 * get_bssid - Get the current BSSID
247 	 * @priv: private driver interface data
248 	 * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
249 	 *
250 	 * Returns: 0 on success, -1 on failure
251 	 *
252 	 * Query kernel driver for the current BSSID and copy it to bssid.
253 	 * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
254 	 * associated.
255 	 */
256 	int (*get_bssid)(void *priv, u8 *bssid);
257 
258 	/**
259 	 * get_ssid - Get the current SSID
260 	 * @priv: private driver interface data
261 	 * @ssid: buffer for SSID (at least 32 bytes)
262 	 *
263 	 * Returns: Length of the SSID on success, -1 on failure
264 	 *
265 	 * Query kernel driver for the current SSID and copy it to ssid.
266 	 * Returning zero is recommended if the STA is not associated.
267 	 *
268 	 * Note: SSID is an array of octets, i.e., it is not nul terminated and
269 	 * can, at least in theory, contain control characters (including nul)
270 	 * and as such, should be processed as binary data, not a printable
271 	 * string.
272 	 */
273 	int (*get_ssid)(void *priv, u8 *ssid);
274 
275 	/**
276 	 * set_wpa - Enable/disable WPA support (OBSOLETE)
277 	 * @priv: private driver interface data
278 	 * @enabled: 1 = enable, 0 = disable
279 	 *
280 	 * Returns: 0 on success, -1 on failure
281 	 *
282 	 * Note: This function is included for backwards compatibility. This is
283 	 * called only just after init and just before deinit, so these
284 	 * functions can be used to implement same functionality and the driver
285 	 * interface need not define this function.
286 	 *
287 	 * Configure the kernel driver to enable/disable WPA support. This may
288 	 * be empty function, if WPA support is always enabled. Common
289 	 * configuration items are WPA IE (clearing it when WPA support is
290 	 * disabled), Privacy flag configuration for capability field (note:
291 	 * this the value need to set in associate handler to allow plaintext
292 	 * mode to be used) when trying to associate with, roaming mode (can
293 	 * allow wpa_supplicant to control roaming if ap_scan=1 is used;
294 	 * however, drivers can also implement roaming if desired, especially
295 	 * ap_scan=2 mode is used for this).
296 	 */
297 	int (*set_wpa)(void *priv, int enabled);
298 
299 	/**
300 	 * set_key - Configure encryption key
301 	 * @priv: private driver interface data
302 	 * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
303 	 *	%WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_DHV);
304 	 *	%WPA_ALG_NONE clears the key.
305 	 * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
306 	 *	broadcast/default keys
307 	 * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
308 	 *	IGTK
309 	 * @set_tx: configure this key as the default Tx key (only used when
310 	 *	driver does not support separate unicast/individual key
311 	 * @seq: sequence number/packet number, seq_len octets, the next
312 	 *	packet number to be used for in replay protection; configured
313 	 *	for Rx keys (in most cases, this is only used with broadcast
314 	 *	keys and set to zero for unicast keys)
315 	 * @seq_len: length of the seq, depends on the algorithm:
316 	 *	TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
317 	 * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
318 	 *	8-byte Rx Mic Key
319 	 * @key_len: length of the key buffer in octets (WEP: 5 or 13,
320 	 *	TKIP: 32, CCMP: 16, IGTK: 16, DHV: 16)
321 	 *
322 	 * Returns: 0 on success, -1 on failure
323 	 *
324 	 * Configure the given key for the kernel driver. If the driver
325 	 * supports separate individual keys (4 default keys + 1 individual),
326 	 * addr can be used to determine whether the key is default or
327 	 * individual. If only 4 keys are supported, the default key with key
328 	 * index 0 is used as the individual key. STA must be configured to use
329 	 * it as the default Tx key (set_tx is set) and accept Rx for all the
330 	 * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
331 	 * broadcast keys, so key index 0 is available for this kind of
332 	 * configuration.
333 	 *
334 	 * Please note that TKIP keys include separate TX and RX MIC keys and
335 	 * some drivers may expect them in different order than wpa_supplicant
336 	 * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
337 	 * will tricker Michael MIC errors. This can be fixed by changing the
338 	 * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
339 	 * in driver_*.c set_key() implementation, see driver_ndis.c for an
340 	 * example on how this can be done.
341 	 */
342 	int (*set_key)(void *priv, wpa_alg alg, const u8 *addr,
343 		       int key_idx, int set_tx, const u8 *seq, size_t seq_len,
344 		       const u8 *key, size_t key_len);
345 
346 	/**
347 	 * init - Initialize driver interface
348 	 * @ctx: context to be used when calling wpa_supplicant functions,
349 	 * e.g., wpa_supplicant_event()
350 	 * @ifname: interface name, e.g., wlan0
351 	 *
352 	 * Returns: Pointer to private data, %NULL on failure
353 	 *
354 	 * Initialize driver interface, including event processing for kernel
355 	 * driver events (e.g., associated, scan results, Michael MIC failure).
356 	 * This function can allocate a private configuration data area for
357 	 * @ctx, file descriptor, interface name, etc. information that may be
358 	 * needed in future driver operations. If this is not used, non-NULL
359 	 * value will need to be returned because %NULL is used to indicate
360 	 * failure. The returned value will be used as 'void *priv' data for
361 	 * all other driver_ops functions.
362 	 *
363 	 * The main event loop (eloop.c) of wpa_supplicant can be used to
364 	 * register callback for read sockets (eloop_register_read_sock()).
365 	 *
366 	 * See wpa_supplicant.h for more information about events and
367 	 * wpa_supplicant_event() function.
368 	 */
369 	void * (*init)(void *ctx, const char *ifname);
370 
371 	/**
372 	 * deinit - Deinitialize driver interface
373 	 * @priv: private driver interface data from init()
374 	 *
375 	 * Shut down driver interface and processing of driver events. Free
376 	 * private data buffer if one was allocated in init() handler.
377 	 */
378 	void (*deinit)(void *priv);
379 
380 	/**
381 	 * set_param - Set driver configuration parameters
382 	 * @priv: private driver interface data from init()
383 	 * @param: driver specific configuration parameters
384 	 *
385 	 * Returns: 0 on success, -1 on failure
386 	 *
387 	 * Optional handler for notifying driver interface about configuration
388 	 * parameters (driver_param).
389 	 */
390 	int (*set_param)(void *priv, const char *param);
391 
392 	/**
393 	 * set_countermeasures - Enable/disable TKIP countermeasures
394 	 * @priv: private driver interface data
395 	 * @enabled: 1 = countermeasures enabled, 0 = disabled
396 	 *
397 	 * Returns: 0 on success, -1 on failure
398 	 *
399 	 * Configure TKIP countermeasures. When these are enabled, the driver
400 	 * should drop all received and queued frames that are using TKIP.
401 	 */
402 	int (*set_countermeasures)(void *priv, int enabled);
403 
404 	/**
405 	 * set_drop_unencrypted - Enable/disable unencrypted frame filtering
406 	 * @priv: private driver interface data
407 	 * @enabled: 1 = unencrypted Tx/Rx frames will be dropped, 0 = disabled
408 	 *
409 	 * Returns: 0 on success, -1 on failure
410 	 *
411 	 * Configure the driver to drop all non-EAPOL frames (both receive and
412 	 * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
413 	 * still be allowed for key negotiation.
414 	 */
415 	int (*set_drop_unencrypted)(void *priv, int enabled);
416 
417 	/**
418 	 * scan - Request the driver to initiate scan
419 	 * @priv: private driver interface data
420 	 * @ssid: specific SSID to scan for (ProbeReq) or %NULL to scan for
421 	 *	all SSIDs (either active scan with broadcast SSID or passive
422 	 *	scan
423 	 * @ssid_len: length of the SSID
424 	 *
425 	 * Returns: 0 on success, -1 on failure
426 	 *
427 	 * Once the scan results are ready, the driver should report scan
428 	 * results event for wpa_supplicant which will eventually request the
429 	 * results with wpa_driver_get_scan_results().
430 	 */
431 	int (*scan)(void *priv, const u8 *ssid, size_t ssid_len);
432 
433 	/**
434 	 * get_scan_results - Fetch the latest scan results
435 	 * @priv: private driver interface data
436 	 * @results: pointer to buffer for scan results
437 	 * @max_size: maximum number of entries (buffer size)
438 	 *
439 	 * Returns: Number of scan result entries used on success, -1 on
440 	 * failure
441 	 *
442 	 * If scan results include more than max_size BSSes, max_size will be
443 	 * returned and the remaining entries will not be included in the
444 	 * buffer.
445 	 */
446 	int (*get_scan_results)(void *priv,
447 				struct wpa_scan_result *results,
448 				size_t max_size);
449 
450 	/**
451 	 * deauthenticate - Request driver to deauthenticate
452 	 * @priv: private driver interface data
453 	 * @addr: peer address (BSSID of the AP)
454 	 * @reason_code: 16-bit reason code to be sent in the deauthentication
455 	 *	frame
456 	 *
457 	 * Returns: 0 on success, -1 on failure
458 	 */
459 	int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
460 
461 	/**
462 	 * disassociate - Request driver to disassociate
463 	 * @priv: private driver interface data
464 	 * @addr: peer address (BSSID of the AP)
465 	 * @reason_code: 16-bit reason code to be sent in the disassociation
466 	 *	frame
467 	 *
468 	 * Returns: 0 on success, -1 on failure
469 	 */
470 	int (*disassociate)(void *priv, const u8 *addr, int reason_code);
471 
472 	/**
473 	 * associate - Request driver to associate
474 	 * @priv: private driver interface data
475 	 * @params: association parameters
476 	 *
477 	 * Returns: 0 on success, -1 on failure
478 	 */
479 	int (*associate)(void *priv,
480 			 struct wpa_driver_associate_params *params);
481 
482 	/**
483 	 * set_auth_alg - Set IEEE 802.11 authentication algorithm
484 	 * @priv: private driver interface data
485 	 * @auth_alg: bit field of AUTH_ALG_*
486 	 *
487 	 * If the driver supports more than one authentication algorithm at the
488 	 * same time, it should configure all supported algorithms. If not, one
489 	 * algorithm needs to be selected arbitrarily. Open System
490 	 * authentication should be ok for most cases and it is recommended to
491 	 * be used if other options are not supported. Static WEP configuration
492 	 * may also use Shared Key authentication and LEAP requires its own
493 	 * algorithm number. For LEAP, user can make sure that only one
494 	 * algorithm is used at a time by configuring LEAP as the only
495 	 * supported EAP method. This information is also available in
496 	 * associate() params, so set_auth_alg may not be needed in case of
497 	 * most drivers.
498 	 *
499 	 * Returns: 0 on success, -1 on failure
500 	 */
501 	int (*set_auth_alg)(void *priv, int auth_alg);
502 
503 	/**
504 	 * add_pmkid - Add PMKSA cache entry to the driver
505 	 * @priv: private driver interface data
506 	 * @bssid: BSSID for the PMKSA cache entry
507 	 * @pmkid: PMKID for the PMKSA cache entry
508 	 *
509 	 * Returns: 0 on success, -1 on failure
510 	 *
511 	 * This function is called when a new PMK is received, as a result of
512 	 * either normal authentication or RSN pre-authentication.
513 	 *
514 	 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
515 	 * associate(), add_pmkid() can be used to add new PMKSA cache entries
516 	 * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
517 	 * driver_ops function does not need to be implemented. Likewise, if
518 	 * the driver does not support WPA, this function is not needed.
519 	 */
520 	int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
521 
522 	/**
523 	 * remove_pmkid - Remove PMKSA cache entry to the driver
524 	 * @priv: private driver interface data
525 	 * @bssid: BSSID for the PMKSA cache entry
526 	 * @pmkid: PMKID for the PMKSA cache entry
527 	 *
528 	 * Returns: 0 on success, -1 on failure
529 	 *
530 	 * This function is called when the supplicant drops a PMKSA cache
531 	 * entry for any reason.
532 	 *
533 	 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
534 	 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
535 	 * between the driver and wpa_supplicant. If the driver uses wpa_ie
536 	 * from wpa_supplicant, this driver_ops function does not need to be
537 	 * implemented. Likewise, if the driver does not support WPA, this
538 	 * function is not needed.
539 	 */
540 	int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
541 
542 	/**
543 	 * flush_pmkid - Flush PMKSA cache
544 	 * @priv: private driver interface data
545 	 *
546 	 * Returns: 0 on success, -1 on failure
547 	 *
548 	 * This function is called when the supplicant drops all PMKSA cache
549 	 * entries for any reason.
550 	 *
551 	 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
552 	 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
553 	 * between the driver and wpa_supplicant. If the driver uses wpa_ie
554 	 * from wpa_supplicant, this driver_ops function does not need to be
555 	 * implemented. Likewise, if the driver does not support WPA, this
556 	 * function is not needed.
557 	 */
558 	int (*flush_pmkid)(void *priv);
559 
560 	/**
561 	 * flush_pmkid - Flush PMKSA cache
562 	 * @priv: private driver interface data
563 	 *
564 	 * Returns: 0 on success, -1 on failure
565 	 *
566 	 * Get driver/firmware/hardware capabilities.
567 	 */
568 	int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
569 
570 	/**
571 	 * poll - Poll driver for association information
572 	 * @priv: private driver interface data
573 	 *
574 	 * This is an option callback that can be used when the driver does not
575 	 * provide event mechanism for association events. This is called when
576 	 * receiving WPA EAPOL-Key messages that require association
577 	 * information. The driver interface is supposed to generate associnfo
578 	 * event before returning from this callback function. In addition, the
579 	 * driver interface should generate an association event after having
580 	 * sent out associnfo.
581 	 */
582 	void (*poll)(void *priv);
583 
584 	/**
585 	 * get_ifname - Get interface name
586 	 * @priv: private driver interface data
587 	 *
588 	 * Returns: Pointer to the interface name. This can differ from the
589 	 * interface name used in init() call.
590 	 *
591 	 * This optional function can be used to allow the driver interface to
592 	 * replace the interface name with something else, e.g., based on an
593 	 * interface mapping from a more descriptive name.
594 	 */
595 	const char * (*get_ifname)(void *priv);
596 
597 	/**
598 	 * get_mac_addr - Get own MAC address
599 	 * @priv: private driver interface data
600 	 *
601 	 * Returns: Pointer to own MAC address or %NULL on failure
602 	 *
603 	 * This optional function can be used to get the own MAC address of the
604 	 * device from the driver interface code. This is only needed if the
605 	 * l2_packet implementation for the OS does not provide easy access to
606 	 * a MAC address. */
607 	const u8 * (*get_mac_addr)(void *priv);
608 
609 	/**
610 	 * send_eapol - Optional function for sending EAPOL packets
611 	 * @priv: private driver interface data
612 	 * @dest: Destination MAC address
613 	 * @proto: Ethertype
614 	 * @data: EAPOL packet starting with IEEE 802.1X header
615 	 * @data_len: Size of the EAPOL packet
616 	 *
617 	 * Returns: 0 on success, -1 on failure
618 	 *
619 	 * This optional function can be used to override l2_packet operations
620 	 * with driver specific functionality. If this function pointer is set,
621 	 * l2_packet module is not used at all and the driver interface code is
622 	 * responsible for receiving and sending all EAPOL packets. The
623 	 * received EAPOL packets are sent to core code by calling
624 	 * wpa_supplicant_rx_eapol(). The driver interface is required to
625 	 * implement get_mac_addr() handler if send_eapol() is used.
626 	 */
627 	int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
628 			  const u8 *data, size_t data_len);
629 
630 	/**
631 	 * set_operstate - Sets device operating state to DORMANT or UP
632 	 * @priv: private driver interface data
633 	 * @state: 0 = dormant, 1 = up
634 	 * Returns: 0 on success, -1 on failure
635 	 *
636 	 * This is an optional function that can be used on operating systems
637 	 * that support a concept of controlling network device state from user
638 	 * space applications. This function, if set, gets called with
639 	 * state = 1 when authentication has been completed and with state = 0
640 	 * when connection is lost.
641 	 */
642 	int (*set_operstate)(void *priv, int state);
643 
644 	/**
645 	 * mlme_setprotection - MLME-SETPROTECTION.request primitive
646 	 * @priv: Private driver interface data
647 	 * @addr: Address of the station for which to set protection (may be
648 	 * %NULL for group keys)
649 	 * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
650 	 * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
651 	 * Returns: 0 on success, -1 on failure
652 	 *
653 	 * This is an optional function that can be used to set the driver to
654 	 * require protection for Tx and/or Rx frames. This uses the layer
655 	 * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
656 	 * (MLME-SETPROTECTION.request). Many drivers do not use explicit
657 	 * set protection operation; instead, they set protection implicitly
658 	 * based on configured keys.
659 	 */
660 	int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
661 				  int key_type);
662 
663 	/**
664 	 * get_hw_feature_data - Get hardware support data (channels and rates)
665 	 * @priv: Private driver interface data
666 	 * @num_modes: Variable for returning the number of returned modes
667 	 * flags: Variable for returning hardware feature flags
668 	 * Returns: Pointer to allocated hardware data on success or %NULL on
669 	 * failure. Caller is responsible for freeing this.
670 	 *
671 	 * This function is only needed for drivers that export MLME
672 	 * (management frame processing) to wpa_supplicant.
673 	 */
674 	struct wpa_hw_modes * (*get_hw_feature_data)(void *priv,
675 						     u16 *num_modes,
676 						     u16 *flags);
677 
678 	/**
679 	 * set_channel - Set channel
680 	 * @priv: Private driver interface data
681 	 * @phymode: WPA_MODE_IEEE80211B, ..
682 	 * @chan: IEEE 802.11 channel number
683 	 * @freq: Frequency of the channel in MHz
684 	 * Returns: 0 on success, -1 on failure
685 	 *
686 	 * This function is only needed for drivers that export MLME
687 	 * (management frame processing) to wpa_supplicant.
688 	 */
689 	int (*set_channel)(void *priv, wpa_hw_mode phymode, int chan,
690 			   int freq);
691 
692 	/**
693 	 * set_ssid - Set SSID
694 	 * @priv: Private driver interface data
695 	 * @ssid: SSID
696 	 * @ssid_len: SSID length
697 	 * Returns: 0 on success, -1 on failure
698 	 *
699 	 * This function is only needed for drivers that export MLME
700 	 * (management frame processing) to wpa_supplicant.
701 	 */
702 	int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
703 
704 	/**
705 	 * set_bssid - Set BSSID
706 	 * @priv: Private driver interface data
707 	 * @bssid: BSSID
708 	 * Returns: 0 on success, -1 on failure
709 	 *
710 	 * This function is only needed for drivers that export MLME
711 	 * (management frame processing) to wpa_supplicant.
712 	 */
713 	int (*set_bssid)(void *priv, const u8 *bssid);
714 
715 	/**
716 	 * send_mlme - Send management frame from MLME
717 	 * @priv: Private driver interface data
718 	 * @data: IEEE 802.11 management frame with IEEE 802.11 header
719 	 * @data_len: Size of the management frame
720 	 * Returns: 0 on success, -1 on failure
721 	 *
722 	 * This function is only needed for drivers that export MLME
723 	 * (management frame processing) to wpa_supplicant.
724 	 */
725 	int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
726 
727 	/**
728 	 * mlme_add_sta - Add a STA entry into the driver/netstack
729 	 * @priv: Private driver interface data
730 	 * @addr: MAC address of the STA (e.g., BSSID of the AP)
731 	 * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
732 	 * format (one octet per rate, 1 = 0.5 Mbps)
733 	 * @supp_rates_len: Number of entries in supp_rates
734 	 * Returns: 0 on success, -1 on failure
735 	 *
736 	 * This function is only needed for drivers that export MLME
737 	 * (management frame processing) to wpa_supplicant. When the MLME code
738 	 * completes association with an AP, this function is called to
739 	 * configure the driver/netstack with a STA entry for data frame
740 	 * processing (TX rate control, encryption/decryption).
741 	 */
742 	 int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
743 			     size_t supp_rates_len);
744 
745 	/**
746 	 * mlme_remove_sta - Remove a STA entry from the driver/netstack
747 	 * @priv: Private driver interface data
748 	 * @addr: MAC address of the STA (e.g., BSSID of the AP)
749 	 * Returns: 0 on success, -1 on failure
750 	 *
751 	 * This function is only needed for drivers that export MLME
752 	 * (management frame processing) to wpa_supplicant.
753 	 */
754 	 int (*mlme_remove_sta)(void *priv, const u8 *addr);
755 
756     /**
757      * driver_cmd - execute driver-specific command
758      * @priv: private driver interface data from init()
759      * @cmd: command to execute
760      * @buf: return buffer
761      * @buf_len: buffer length
762 	 *
763 	 * Returns: 0 on success, -1 on failure
764 	 *
765 	 */
766      int (*driver_cmd)(void *priv, char *cmd, char *buf, size_t buf_len);
767 };
768 
769 #endif /* DRIVER_H */
770