driver.h 50 KB

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