driver.h 50 KB

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