driver.h 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468
  1. /*
  2. * Driver interface definition
  3. * Copyright (c) 2003-2010, 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. * This file defines a driver interface used by both %wpa_supplicant and
  15. * hostapd. The first part of the file defines data structures used in various
  16. * driver operations. This is followed by the struct wpa_driver_ops that each
  17. * driver wrapper will beed to define with callback functions for requesting
  18. * driver operations. After this, there are definitions for driver event
  19. * reporting with wpa_supplicant_event() and some convenience helper functions
  20. * that can be used to report events.
  21. */
  22. #ifndef DRIVER_H
  23. #define DRIVER_H
  24. #define WPA_SUPPLICANT_DRIVER_VERSION 4
  25. #include "common/defs.h"
  26. #define HOSTAPD_CHAN_DISABLED 0x00000001
  27. #define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
  28. #define HOSTAPD_CHAN_NO_IBSS 0x00000004
  29. #define HOSTAPD_CHAN_RADAR 0x00000008
  30. /**
  31. * struct hostapd_channel_data - Channel information
  32. */
  33. struct hostapd_channel_data {
  34. /**
  35. * chan - Channel number (IEEE 802.11)
  36. */
  37. short chan;
  38. /**
  39. * freq - Frequency in MHz
  40. */
  41. short freq;
  42. /**
  43. * flag - Channel flags (HOSTAPD_CHAN_*)
  44. */
  45. int flag;
  46. /**
  47. * max_tx_power - maximum transmit power in dBm
  48. */
  49. u8 max_tx_power;
  50. };
  51. /**
  52. * struct hostapd_hw_modes - Supported hardware mode information
  53. */
  54. struct hostapd_hw_modes {
  55. /**
  56. * mode - Hardware mode
  57. */
  58. enum hostapd_hw_mode mode;
  59. /**
  60. * num_channels - Number of entries in the channels array
  61. */
  62. int num_channels;
  63. /**
  64. * channels - Array of supported channels
  65. */
  66. struct hostapd_channel_data *channels;
  67. /**
  68. * num_rates - Number of entries in the rates array
  69. */
  70. int num_rates;
  71. /**
  72. * rates - Array of supported rates in 100 kbps units
  73. */
  74. int *rates;
  75. /**
  76. * ht_capab - HT (IEEE 802.11n) capabilities
  77. */
  78. u16 ht_capab;
  79. /**
  80. * mcs_set - MCS (IEEE 802.11n) rate parameters
  81. */
  82. u8 mcs_set[16];
  83. /**
  84. * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
  85. */
  86. u8 a_mpdu_params;
  87. };
  88. #define IEEE80211_MODE_INFRA 0
  89. #define IEEE80211_MODE_IBSS 1
  90. #define IEEE80211_MODE_AP 2
  91. #define IEEE80211_CAP_ESS 0x0001
  92. #define IEEE80211_CAP_IBSS 0x0002
  93. #define IEEE80211_CAP_PRIVACY 0x0010
  94. #define WPA_SCAN_QUAL_INVALID BIT(0)
  95. #define WPA_SCAN_NOISE_INVALID BIT(1)
  96. #define WPA_SCAN_LEVEL_INVALID BIT(2)
  97. #define WPA_SCAN_LEVEL_DBM BIT(3)
  98. #define WPA_SCAN_AUTHENTICATED BIT(4)
  99. #define WPA_SCAN_ASSOCIATED BIT(5)
  100. /**
  101. * struct wpa_scan_res - Scan result for an BSS/IBSS
  102. * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
  103. * @bssid: BSSID
  104. * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
  105. * @beacon_int: beacon interval in TUs (host byte order)
  106. * @caps: capability information field in host byte order
  107. * @qual: signal quality
  108. * @noise: noise level
  109. * @level: signal level
  110. * @tsf: Timestamp
  111. * @age: Age of the information in milliseconds (i.e., how many milliseconds
  112. * ago the last Beacon or Probe Response frame was received)
  113. * @ie_len: length of the following IE field in octets
  114. * @beacon_ie_len: length of the following Beacon IE field in octets
  115. *
  116. * This structure is used as a generic format for scan results from the
  117. * driver. Each driver interface implementation is responsible for converting
  118. * the driver or OS specific scan results into this format.
  119. *
  120. * If the driver does not support reporting all IEs, the IE data structure is
  121. * constructed of the IEs that are available. This field will also need to
  122. * include SSID in IE format. All drivers are encouraged to be extended to
  123. * report all IEs to make it easier to support future additions.
  124. */
  125. struct wpa_scan_res {
  126. unsigned int flags;
  127. u8 bssid[ETH_ALEN];
  128. int freq;
  129. u16 beacon_int;
  130. u16 caps;
  131. int qual;
  132. int noise;
  133. int level;
  134. u64 tsf;
  135. unsigned int age;
  136. size_t ie_len;
  137. size_t beacon_ie_len;
  138. /*
  139. * Followed by ie_len octets of IEs from Probe Response frame (or if
  140. * the driver does not indicate source of IEs, these may also be from
  141. * Beacon frame). After the first set of IEs, another set of IEs may
  142. * follow (with beacon_ie_len octets of data) if the driver provides
  143. * both IE sets.
  144. */
  145. };
  146. /**
  147. * struct wpa_scan_results - Scan results
  148. * @res: Array of pointers to allocated variable length scan result entries
  149. * @num: Number of entries in the scan result array
  150. */
  151. struct wpa_scan_results {
  152. struct wpa_scan_res **res;
  153. size_t num;
  154. };
  155. /**
  156. * struct wpa_interface_info - Network interface information
  157. * @next: Pointer to the next interface or NULL if this is the last one
  158. * @ifname: Interface name that can be used with init() or init2()
  159. * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
  160. * not available
  161. * @drv_name: struct wpa_driver_ops::name (note: unlike other strings, this one
  162. * is not an allocated copy, i.e., get_interfaces() caller will not free
  163. * this)
  164. */
  165. struct wpa_interface_info {
  166. struct wpa_interface_info *next;
  167. char *ifname;
  168. char *desc;
  169. const char *drv_name;
  170. };
  171. #define WPAS_MAX_SCAN_SSIDS 4
  172. /**
  173. * struct wpa_driver_scan_params - Scan parameters
  174. * Data for struct wpa_driver_ops::scan2().
  175. */
  176. struct wpa_driver_scan_params {
  177. /**
  178. * ssids - SSIDs to scan for
  179. */
  180. struct wpa_driver_scan_ssid {
  181. /**
  182. * ssid - specific SSID to scan for (ProbeReq)
  183. * %NULL or zero-length SSID is used to indicate active scan
  184. * with wildcard SSID.
  185. */
  186. const u8 *ssid;
  187. /**
  188. * ssid_len: Length of the SSID in octets
  189. */
  190. size_t ssid_len;
  191. } ssids[WPAS_MAX_SCAN_SSIDS];
  192. /**
  193. * num_ssids - Number of entries in ssids array
  194. * Zero indicates a request for a passive scan.
  195. */
  196. size_t num_ssids;
  197. /**
  198. * extra_ies - Extra IE(s) to add into Probe Request or %NULL
  199. */
  200. const u8 *extra_ies;
  201. /**
  202. * extra_ies_len - Length of extra_ies in octets
  203. */
  204. size_t extra_ies_len;
  205. /**
  206. * freqs - Array of frequencies to scan or %NULL for all frequencies
  207. *
  208. * The frequency is set in MHz. The array is zero-terminated.
  209. */
  210. int *freqs;
  211. /**
  212. * filter_ssids - Filter for reporting SSIDs
  213. *
  214. * This optional parameter can be used to request the driver wrapper to
  215. * filter scan results to include only the specified SSIDs. %NULL
  216. * indicates that no filtering is to be done. This can be used to
  217. * reduce memory needs for scan results in environments that have large
  218. * number of APs with different SSIDs.
  219. *
  220. * The driver wrapper is allowed to take this allocated buffer into its
  221. * own use by setting the pointer to %NULL. In that case, the driver
  222. * wrapper is responsible for freeing the buffer with os_free() once it
  223. * is not needed anymore.
  224. */
  225. struct wpa_driver_scan_filter {
  226. u8 ssid[32];
  227. size_t ssid_len;
  228. } *filter_ssids;
  229. /**
  230. * num_filter_ssids - Number of entries in filter_ssids array
  231. */
  232. size_t num_filter_ssids;
  233. };
  234. /**
  235. * struct wpa_driver_auth_params - Authentication parameters
  236. * Data for struct wpa_driver_ops::authenticate().
  237. */
  238. struct wpa_driver_auth_params {
  239. int freq;
  240. const u8 *bssid;
  241. const u8 *ssid;
  242. size_t ssid_len;
  243. int auth_alg;
  244. const u8 *ie;
  245. size_t ie_len;
  246. const u8 *wep_key[4];
  247. size_t wep_key_len[4];
  248. int wep_tx_keyidx;
  249. };
  250. /**
  251. * struct wpa_driver_associate_params - Association parameters
  252. * Data for struct wpa_driver_ops::associate().
  253. */
  254. struct wpa_driver_associate_params {
  255. /**
  256. * bssid - BSSID of the selected AP
  257. * This can be %NULL, if ap_scan=2 mode is used and the driver is
  258. * responsible for selecting with which BSS to associate. */
  259. const u8 *bssid;
  260. /**
  261. * ssid - The selected SSID
  262. */
  263. const u8 *ssid;
  264. /**
  265. * ssid_len - Length of the SSID (1..32)
  266. */
  267. size_t ssid_len;
  268. /**
  269. * freq - Frequency of the channel the selected AP is using
  270. * Frequency that the selected AP is using (in MHz as
  271. * reported in the scan results)
  272. */
  273. int freq;
  274. /**
  275. * wpa_ie - WPA information element for (Re)Association Request
  276. * WPA information element to be included in (Re)Association
  277. * Request (including information element id and length). Use
  278. * of this WPA IE is optional. If the driver generates the WPA
  279. * IE, it can use pairwise_suite, group_suite, and
  280. * key_mgmt_suite to select proper algorithms. In this case,
  281. * the driver has to notify wpa_supplicant about the used WPA
  282. * IE by generating an event that the interface code will
  283. * convert into EVENT_ASSOCINFO data (see below).
  284. *
  285. * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
  286. * instead. The driver can determine which version is used by
  287. * looking at the first byte of the IE (0xdd for WPA, 0x30 for
  288. * WPA2/RSN).
  289. *
  290. * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
  291. */
  292. const u8 *wpa_ie;
  293. /**
  294. * wpa_ie_len - length of the wpa_ie
  295. */
  296. size_t wpa_ie_len;
  297. /**
  298. * pairwise_suite - Selected pairwise cipher suite
  299. *
  300. * This is usually ignored if @wpa_ie is used.
  301. */
  302. enum wpa_cipher pairwise_suite;
  303. /**
  304. * group_suite - Selected group cipher suite
  305. *
  306. * This is usually ignored if @wpa_ie is used.
  307. */
  308. enum wpa_cipher group_suite;
  309. /**
  310. * key_mgmt_suite - Selected key management suite
  311. *
  312. * This is usually ignored if @wpa_ie is used.
  313. */
  314. enum wpa_key_mgmt key_mgmt_suite;
  315. /**
  316. * auth_alg - Allowed authentication algorithms
  317. * Bit field of WPA_AUTH_ALG_*
  318. */
  319. int auth_alg;
  320. /**
  321. * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
  322. */
  323. int mode;
  324. /**
  325. * wep_key - WEP keys for static WEP configuration
  326. */
  327. const u8 *wep_key[4];
  328. /**
  329. * wep_key_len - WEP key length for static WEP configuration
  330. */
  331. size_t wep_key_len[4];
  332. /**
  333. * wep_tx_keyidx - WEP TX key index for static WEP configuration
  334. */
  335. int wep_tx_keyidx;
  336. /**
  337. * mgmt_frame_protection - IEEE 802.11w management frame protection
  338. */
  339. enum mfp_options mgmt_frame_protection;
  340. /**
  341. * ft_ies - IEEE 802.11r / FT information elements
  342. * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
  343. * for fast transition, this parameter is set to include the IEs that
  344. * are to be sent in the next FT Authentication Request message.
  345. * update_ft_ies() handler is called to update the IEs for further
  346. * FT messages in the sequence.
  347. *
  348. * The driver should use these IEs only if the target AP is advertising
  349. * the same mobility domain as the one included in the MDIE here.
  350. *
  351. * In ap_scan=2 mode, the driver can use these IEs when moving to a new
  352. * AP after the initial association. These IEs can only be used if the
  353. * target AP is advertising support for FT and is using the same MDIE
  354. * and SSID as the current AP.
  355. *
  356. * The driver is responsible for reporting the FT IEs received from the
  357. * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
  358. * type. update_ft_ies() handler will then be called with the FT IEs to
  359. * include in the next frame in the authentication sequence.
  360. */
  361. const u8 *ft_ies;
  362. /**
  363. * ft_ies_len - Length of ft_ies in bytes
  364. */
  365. size_t ft_ies_len;
  366. /**
  367. * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
  368. *
  369. * This value is provided to allow the driver interface easier access
  370. * to the current mobility domain. This value is set to %NULL if no
  371. * mobility domain is currently active.
  372. */
  373. const u8 *ft_md;
  374. /**
  375. * passphrase - RSN passphrase for PSK
  376. *
  377. * This value is made available only for WPA/WPA2-Personal (PSK) and
  378. * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
  379. * the 8..63 character ASCII passphrase, if available. Please note that
  380. * this can be %NULL if passphrase was not used to generate the PSK. In
  381. * that case, the psk field must be used to fetch the PSK.
  382. */
  383. const char *passphrase;
  384. /**
  385. * psk - RSN PSK (alternative for passphrase for PSK)
  386. *
  387. * This value is made available only for WPA/WPA2-Personal (PSK) and
  388. * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
  389. * the 32-octet (256-bit) PSK, if available. The driver wrapper should
  390. * be prepared to handle %NULL value as an error.
  391. */
  392. const u8 *psk;
  393. /**
  394. * drop_unencrypted - Enable/disable unencrypted frame filtering
  395. *
  396. * Configure the driver to drop all non-EAPOL frames (both receive and
  397. * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
  398. * still be allowed for key negotiation.
  399. */
  400. int drop_unencrypted;
  401. /**
  402. * prev_bssid - Previously used BSSID in this ESS
  403. *
  404. * When not %NULL, this is a request to use reassociation instead of
  405. * association.
  406. */
  407. const u8 *prev_bssid;
  408. };
  409. /**
  410. * struct wpa_driver_capa - Driver capability information
  411. */
  412. struct wpa_driver_capa {
  413. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
  414. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
  415. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK 0x00000004
  416. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK 0x00000008
  417. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE 0x00000010
  418. #define WPA_DRIVER_CAPA_KEY_MGMT_FT 0x00000020
  419. #define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK 0x00000040
  420. unsigned int key_mgmt;
  421. #define WPA_DRIVER_CAPA_ENC_WEP40 0x00000001
  422. #define WPA_DRIVER_CAPA_ENC_WEP104 0x00000002
  423. #define WPA_DRIVER_CAPA_ENC_TKIP 0x00000004
  424. #define WPA_DRIVER_CAPA_ENC_CCMP 0x00000008
  425. unsigned int enc;
  426. #define WPA_DRIVER_AUTH_OPEN 0x00000001
  427. #define WPA_DRIVER_AUTH_SHARED 0x00000002
  428. #define WPA_DRIVER_AUTH_LEAP 0x00000004
  429. unsigned int auth;
  430. /* Driver generated WPA/RSN IE */
  431. #define WPA_DRIVER_FLAGS_DRIVER_IE 0x00000001
  432. /* Driver needs static WEP key setup after association command */
  433. #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
  434. #define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
  435. /* Driver takes care of RSN 4-way handshake internally; PMK is configured with
  436. * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
  437. #define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
  438. #define WPA_DRIVER_FLAGS_WIRED 0x00000010
  439. /* Driver provides separate commands for authentication and association (SME in
  440. * wpa_supplicant). */
  441. #define WPA_DRIVER_FLAGS_SME 0x00000020
  442. /* Driver supports AP mode */
  443. #define WPA_DRIVER_FLAGS_AP 0x00000040
  444. /* Driver needs static WEP key setup after association has been completed */
  445. #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE 0x00000080
  446. unsigned int flags;
  447. int max_scan_ssids;
  448. };
  449. struct hostapd_data;
  450. struct hostap_sta_driver_data {
  451. unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
  452. unsigned long current_tx_rate;
  453. unsigned long inactive_msec;
  454. unsigned long flags;
  455. unsigned long num_ps_buf_frames;
  456. unsigned long tx_retry_failed;
  457. unsigned long tx_retry_count;
  458. int last_rssi;
  459. int last_ack_rssi;
  460. };
  461. struct hostapd_sta_add_params {
  462. const u8 *addr;
  463. u16 aid;
  464. u16 capability;
  465. const u8 *supp_rates;
  466. size_t supp_rates_len;
  467. u16 listen_interval;
  468. const struct ieee80211_ht_capabilities *ht_capabilities;
  469. };
  470. struct hostapd_freq_params {
  471. int mode;
  472. int freq;
  473. int channel;
  474. int ht_enabled;
  475. int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
  476. * secondary channel below primary, 1 = HT40
  477. * enabled, secondary channel above primary */
  478. };
  479. enum wpa_driver_if_type {
  480. /**
  481. * WPA_IF_STATION - Station mode interface
  482. */
  483. WPA_IF_STATION,
  484. /**
  485. * WPA_IF_AP_VLAN - AP mode VLAN interface
  486. *
  487. * This interface shares its address and Beacon frame with the main
  488. * BSS.
  489. */
  490. WPA_IF_AP_VLAN,
  491. /**
  492. * WPA_IF_AP_BSS - AP mode BSS interface
  493. *
  494. * This interface has its own address and Beacon frame.
  495. */
  496. WPA_IF_AP_BSS,
  497. };
  498. struct wpa_init_params {
  499. const u8 *bssid;
  500. const char *ifname;
  501. const u8 *ssid;
  502. size_t ssid_len;
  503. const char *test_socket;
  504. int use_pae_group_addr;
  505. char **bridge;
  506. size_t num_bridge;
  507. u8 *own_addr; /* buffer for writing own MAC address */
  508. };
  509. struct wpa_bss_params {
  510. /** Interface name (for multi-SSID/VLAN support) */
  511. const char *ifname;
  512. /** Whether IEEE 802.1X or WPA/WPA2 is enabled */
  513. int enabled;
  514. int wpa;
  515. int ieee802_1x;
  516. int wpa_group;
  517. int wpa_pairwise;
  518. int wpa_key_mgmt;
  519. int rsn_preauth;
  520. };
  521. #define WPA_STA_AUTHORIZED BIT(0)
  522. #define WPA_STA_WMM BIT(1)
  523. #define WPA_STA_SHORT_PREAMBLE BIT(2)
  524. #define WPA_STA_MFP BIT(3)
  525. /**
  526. * struct wpa_driver_ops - Driver interface API definition
  527. *
  528. * This structure defines the API that each driver interface needs to implement
  529. * for core wpa_supplicant code. All driver specific functionality is captured
  530. * in this wrapper.
  531. */
  532. struct wpa_driver_ops {
  533. /** Name of the driver interface */
  534. const char *name;
  535. /** One line description of the driver interface */
  536. const char *desc;
  537. /**
  538. * get_bssid - Get the current BSSID
  539. * @priv: private driver interface data
  540. * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
  541. *
  542. * Returns: 0 on success, -1 on failure
  543. *
  544. * Query kernel driver for the current BSSID and copy it to bssid.
  545. * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
  546. * associated.
  547. */
  548. int (*get_bssid)(void *priv, u8 *bssid);
  549. /**
  550. * get_ssid - Get the current SSID
  551. * @priv: private driver interface data
  552. * @ssid: buffer for SSID (at least 32 bytes)
  553. *
  554. * Returns: Length of the SSID on success, -1 on failure
  555. *
  556. * Query kernel driver for the current SSID and copy it to ssid.
  557. * Returning zero is recommended if the STA is not associated.
  558. *
  559. * Note: SSID is an array of octets, i.e., it is not nul terminated and
  560. * can, at least in theory, contain control characters (including nul)
  561. * and as such, should be processed as binary data, not a printable
  562. * string.
  563. */
  564. int (*get_ssid)(void *priv, u8 *ssid);
  565. /**
  566. * set_key - Configure encryption key
  567. * @ifname: Interface name (for multi-SSID/VLAN support)
  568. * @priv: private driver interface data
  569. * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
  570. * %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
  571. * %WPA_ALG_NONE clears the key.
  572. * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
  573. * broadcast/default keys
  574. * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
  575. * IGTK
  576. * @set_tx: configure this key as the default Tx key (only used when
  577. * driver does not support separate unicast/individual key
  578. * @seq: sequence number/packet number, seq_len octets, the next
  579. * packet number to be used for in replay protection; configured
  580. * for Rx keys (in most cases, this is only used with broadcast
  581. * keys and set to zero for unicast keys)
  582. * @seq_len: length of the seq, depends on the algorithm:
  583. * TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
  584. * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
  585. * 8-byte Rx Mic Key
  586. * @key_len: length of the key buffer in octets (WEP: 5 or 13,
  587. * TKIP: 32, CCMP: 16, IGTK: 16)
  588. *
  589. * Returns: 0 on success, -1 on failure
  590. *
  591. * Configure the given key for the kernel driver. If the driver
  592. * supports separate individual keys (4 default keys + 1 individual),
  593. * addr can be used to determine whether the key is default or
  594. * individual. If only 4 keys are supported, the default key with key
  595. * index 0 is used as the individual key. STA must be configured to use
  596. * it as the default Tx key (set_tx is set) and accept Rx for all the
  597. * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
  598. * broadcast keys, so key index 0 is available for this kind of
  599. * configuration.
  600. *
  601. * Please note that TKIP keys include separate TX and RX MIC keys and
  602. * some drivers may expect them in different order than wpa_supplicant
  603. * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
  604. * will tricker Michael MIC errors. This can be fixed by changing the
  605. * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
  606. * in driver_*.c set_key() implementation, see driver_ndis.c for an
  607. * example on how this can be done.
  608. */
  609. int (*set_key)(const char *ifname, void *priv, enum wpa_alg alg,
  610. const u8 *addr, int key_idx, int set_tx,
  611. const u8 *seq, size_t seq_len,
  612. const u8 *key, size_t key_len);
  613. /**
  614. * init - Initialize driver interface
  615. * @ctx: context to be used when calling wpa_supplicant functions,
  616. * e.g., wpa_supplicant_event()
  617. * @ifname: interface name, e.g., wlan0
  618. *
  619. * Returns: Pointer to private data, %NULL on failure
  620. *
  621. * Initialize driver interface, including event processing for kernel
  622. * driver events (e.g., associated, scan results, Michael MIC failure).
  623. * This function can allocate a private configuration data area for
  624. * @ctx, file descriptor, interface name, etc. information that may be
  625. * needed in future driver operations. If this is not used, non-NULL
  626. * value will need to be returned because %NULL is used to indicate
  627. * failure. The returned value will be used as 'void *priv' data for
  628. * all other driver_ops functions.
  629. *
  630. * The main event loop (eloop.c) of wpa_supplicant can be used to
  631. * register callback for read sockets (eloop_register_read_sock()).
  632. *
  633. * See below for more information about events and
  634. * wpa_supplicant_event() function.
  635. */
  636. void * (*init)(void *ctx, const char *ifname);
  637. /**
  638. * deinit - Deinitialize driver interface
  639. * @priv: private driver interface data from init()
  640. *
  641. * Shut down driver interface and processing of driver events. Free
  642. * private data buffer if one was allocated in init() handler.
  643. */
  644. void (*deinit)(void *priv);
  645. /**
  646. * set_param - Set driver configuration parameters
  647. * @priv: private driver interface data from init()
  648. * @param: driver specific configuration parameters
  649. *
  650. * Returns: 0 on success, -1 on failure
  651. *
  652. * Optional handler for notifying driver interface about configuration
  653. * parameters (driver_param).
  654. */
  655. int (*set_param)(void *priv, const char *param);
  656. /**
  657. * set_countermeasures - Enable/disable TKIP countermeasures
  658. * @priv: private driver interface data
  659. * @enabled: 1 = countermeasures enabled, 0 = disabled
  660. *
  661. * Returns: 0 on success, -1 on failure
  662. *
  663. * Configure TKIP countermeasures. When these are enabled, the driver
  664. * should drop all received and queued frames that are using TKIP.
  665. */
  666. int (*set_countermeasures)(void *priv, int enabled);
  667. /**
  668. * deauthenticate - Request driver to deauthenticate
  669. * @priv: private driver interface data
  670. * @addr: peer address (BSSID of the AP)
  671. * @reason_code: 16-bit reason code to be sent in the deauthentication
  672. * frame
  673. *
  674. * Returns: 0 on success, -1 on failure
  675. */
  676. int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
  677. /**
  678. * disassociate - Request driver to disassociate
  679. * @priv: private driver interface data
  680. * @addr: peer address (BSSID of the AP)
  681. * @reason_code: 16-bit reason code to be sent in the disassociation
  682. * frame
  683. *
  684. * Returns: 0 on success, -1 on failure
  685. */
  686. int (*disassociate)(void *priv, const u8 *addr, int reason_code);
  687. /**
  688. * associate - Request driver to associate
  689. * @priv: private driver interface data
  690. * @params: association parameters
  691. *
  692. * Returns: 0 on success, -1 on failure
  693. */
  694. int (*associate)(void *priv,
  695. struct wpa_driver_associate_params *params);
  696. /**
  697. * add_pmkid - Add PMKSA cache entry to the driver
  698. * @priv: private driver interface data
  699. * @bssid: BSSID for the PMKSA cache entry
  700. * @pmkid: PMKID for the PMKSA cache entry
  701. *
  702. * Returns: 0 on success, -1 on failure
  703. *
  704. * This function is called when a new PMK is received, as a result of
  705. * either normal authentication or RSN pre-authentication.
  706. *
  707. * If the driver generates RSN IE, i.e., it does not use wpa_ie in
  708. * associate(), add_pmkid() can be used to add new PMKSA cache entries
  709. * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
  710. * driver_ops function does not need to be implemented. Likewise, if
  711. * the driver does not support WPA, this function is not needed.
  712. */
  713. int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
  714. /**
  715. * remove_pmkid - Remove PMKSA cache entry to the driver
  716. * @priv: private driver interface data
  717. * @bssid: BSSID for the PMKSA cache entry
  718. * @pmkid: PMKID for the PMKSA cache entry
  719. *
  720. * Returns: 0 on success, -1 on failure
  721. *
  722. * This function is called when the supplicant drops a PMKSA cache
  723. * entry for any reason.
  724. *
  725. * If the driver generates RSN IE, i.e., it does not use wpa_ie in
  726. * associate(), remove_pmkid() can be used to synchronize PMKSA caches
  727. * between the driver and wpa_supplicant. If the driver uses wpa_ie
  728. * from wpa_supplicant, this driver_ops function does not need to be
  729. * implemented. Likewise, if the driver does not support WPA, this
  730. * function is not needed.
  731. */
  732. int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
  733. /**
  734. * flush_pmkid - Flush PMKSA cache
  735. * @priv: private driver interface data
  736. *
  737. * Returns: 0 on success, -1 on failure
  738. *
  739. * This function is called when the supplicant drops all PMKSA cache
  740. * entries for any reason.
  741. *
  742. * If the driver generates RSN IE, i.e., it does not use wpa_ie in
  743. * associate(), remove_pmkid() can be used to synchronize PMKSA caches
  744. * between the driver and wpa_supplicant. If the driver uses wpa_ie
  745. * from wpa_supplicant, this driver_ops function does not need to be
  746. * implemented. Likewise, if the driver does not support WPA, this
  747. * function is not needed.
  748. */
  749. int (*flush_pmkid)(void *priv);
  750. /**
  751. * get_capa - Get driver capabilities
  752. * @priv: private driver interface data
  753. *
  754. * Returns: 0 on success, -1 on failure
  755. *
  756. * Get driver/firmware/hardware capabilities.
  757. */
  758. int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
  759. /**
  760. * poll - Poll driver for association information
  761. * @priv: private driver interface data
  762. *
  763. * This is an option callback that can be used when the driver does not
  764. * provide event mechanism for association events. This is called when
  765. * receiving WPA EAPOL-Key messages that require association
  766. * information. The driver interface is supposed to generate associnfo
  767. * event before returning from this callback function. In addition, the
  768. * driver interface should generate an association event after having
  769. * sent out associnfo.
  770. */
  771. void (*poll)(void *priv);
  772. /**
  773. * get_ifname - Get interface name
  774. * @priv: private driver interface data
  775. *
  776. * Returns: Pointer to the interface name. This can differ from the
  777. * interface name used in init() call. Init() is called first.
  778. *
  779. * This optional function can be used to allow the driver interface to
  780. * replace the interface name with something else, e.g., based on an
  781. * interface mapping from a more descriptive name.
  782. */
  783. const char * (*get_ifname)(void *priv);
  784. /**
  785. * get_mac_addr - Get own MAC address
  786. * @priv: private driver interface data
  787. *
  788. * Returns: Pointer to own MAC address or %NULL on failure
  789. *
  790. * This optional function can be used to get the own MAC address of the
  791. * device from the driver interface code. This is only needed if the
  792. * l2_packet implementation for the OS does not provide easy access to
  793. * a MAC address. */
  794. const u8 * (*get_mac_addr)(void *priv);
  795. /**
  796. * send_eapol - Optional function for sending EAPOL packets
  797. * @priv: private driver interface data
  798. * @dest: Destination MAC address
  799. * @proto: Ethertype
  800. * @data: EAPOL packet starting with IEEE 802.1X header
  801. * @data_len: Size of the EAPOL packet
  802. *
  803. * Returns: 0 on success, -1 on failure
  804. *
  805. * This optional function can be used to override l2_packet operations
  806. * with driver specific functionality. If this function pointer is set,
  807. * l2_packet module is not used at all and the driver interface code is
  808. * responsible for receiving and sending all EAPOL packets. The
  809. * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
  810. * event. The driver interface is required to implement get_mac_addr()
  811. * handler if send_eapol() is used.
  812. */
  813. int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
  814. const u8 *data, size_t data_len);
  815. /**
  816. * set_operstate - Sets device operating state to DORMANT or UP
  817. * @priv: private driver interface data
  818. * @state: 0 = dormant, 1 = up
  819. * Returns: 0 on success, -1 on failure
  820. *
  821. * This is an optional function that can be used on operating systems
  822. * that support a concept of controlling network device state from user
  823. * space applications. This function, if set, gets called with
  824. * state = 1 when authentication has been completed and with state = 0
  825. * when connection is lost.
  826. */
  827. int (*set_operstate)(void *priv, int state);
  828. /**
  829. * mlme_setprotection - MLME-SETPROTECTION.request primitive
  830. * @priv: Private driver interface data
  831. * @addr: Address of the station for which to set protection (may be
  832. * %NULL for group keys)
  833. * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
  834. * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
  835. * Returns: 0 on success, -1 on failure
  836. *
  837. * This is an optional function that can be used to set the driver to
  838. * require protection for Tx and/or Rx frames. This uses the layer
  839. * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
  840. * (MLME-SETPROTECTION.request). Many drivers do not use explicit
  841. * set protection operation; instead, they set protection implicitly
  842. * based on configured keys.
  843. */
  844. int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
  845. int key_type);
  846. /**
  847. * get_hw_feature_data - Get hardware support data (channels and rates)
  848. * @priv: Private driver interface data
  849. * @num_modes: Variable for returning the number of returned modes
  850. * flags: Variable for returning hardware feature flags
  851. * Returns: Pointer to allocated hardware data on success or %NULL on
  852. * failure. Caller is responsible for freeing this.
  853. *
  854. * This function is only needed for drivers that export MLME
  855. * (management frame processing) to %wpa_supplicant or hostapd.
  856. */
  857. struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
  858. u16 *num_modes,
  859. u16 *flags);
  860. /**
  861. * set_channel - Set channel
  862. * @priv: Private driver interface data
  863. * @phymode: HOSTAPD_MODE_IEEE80211B, ..
  864. * @chan: IEEE 802.11 channel number
  865. * @freq: Frequency of the channel in MHz
  866. * Returns: 0 on success, -1 on failure
  867. *
  868. * This function is only needed for drivers that export MLME
  869. * (management frame processing) to wpa_supplicant.
  870. */
  871. int (*set_channel)(void *priv, enum hostapd_hw_mode phymode, int chan,
  872. int freq);
  873. /**
  874. * set_ssid - Set SSID
  875. * @priv: Private driver interface data
  876. * @ssid: SSID
  877. * @ssid_len: SSID length
  878. * Returns: 0 on success, -1 on failure
  879. *
  880. * This function is only needed for drivers that export MLME
  881. * (management frame processing) to wpa_supplicant.
  882. */
  883. int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
  884. /**
  885. * set_bssid - Set BSSID
  886. * @priv: Private driver interface data
  887. * @bssid: BSSID
  888. * Returns: 0 on success, -1 on failure
  889. *
  890. * This function is only needed for drivers that export MLME
  891. * (management frame processing) to wpa_supplicant.
  892. */
  893. int (*set_bssid)(void *priv, const u8 *bssid);
  894. /**
  895. * send_mlme - Send management frame from MLME
  896. * @priv: Private driver interface data
  897. * @data: IEEE 802.11 management frame with IEEE 802.11 header
  898. * @data_len: Size of the management frame
  899. * Returns: 0 on success, -1 on failure
  900. *
  901. * This function is only needed for drivers that export MLME
  902. * (management frame processing) to wpa_supplicant.
  903. */
  904. int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
  905. /**
  906. * mlme_add_sta - Add a STA entry into the driver/netstack
  907. * @priv: Private driver interface data
  908. * @addr: MAC address of the STA (e.g., BSSID of the AP)
  909. * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
  910. * format (one octet per rate, 1 = 0.5 Mbps)
  911. * @supp_rates_len: Number of entries in supp_rates
  912. * Returns: 0 on success, -1 on failure
  913. *
  914. * This function is only needed for drivers that export MLME
  915. * (management frame processing) to wpa_supplicant. When the MLME code
  916. * completes association with an AP, this function is called to
  917. * configure the driver/netstack with a STA entry for data frame
  918. * processing (TX rate control, encryption/decryption).
  919. */
  920. int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
  921. size_t supp_rates_len);
  922. /**
  923. * mlme_remove_sta - Remove a STA entry from the driver/netstack
  924. * @priv: Private driver interface data
  925. * @addr: MAC address of the STA (e.g., BSSID of the AP)
  926. * Returns: 0 on success, -1 on failure
  927. *
  928. * This function is only needed for drivers that export MLME
  929. * (management frame processing) to wpa_supplicant.
  930. */
  931. int (*mlme_remove_sta)(void *priv, const u8 *addr);
  932. /**
  933. * update_ft_ies - Update FT (IEEE 802.11r) IEs
  934. * @priv: Private driver interface data
  935. * @md: Mobility domain (2 octets) (also included inside ies)
  936. * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
  937. * @ies_len: Length of FT IEs in bytes
  938. * Returns: 0 on success, -1 on failure
  939. *
  940. * The supplicant uses this callback to let the driver know that keying
  941. * material for FT is available and that the driver can use the
  942. * provided IEs in the next message in FT authentication sequence.
  943. *
  944. * This function is only needed for driver that support IEEE 802.11r
  945. * (Fast BSS Transition).
  946. */
  947. int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
  948. size_t ies_len);
  949. /**
  950. * send_ft_action - Send FT Action frame (IEEE 802.11r)
  951. * @priv: Private driver interface data
  952. * @action: Action field value
  953. * @target_ap: Target AP address
  954. * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
  955. * @ies_len: Length of FT IEs in bytes
  956. * Returns: 0 on success, -1 on failure
  957. *
  958. * The supplicant uses this callback to request the driver to transmit
  959. * an FT Action frame (action category 6) for over-the-DS fast BSS
  960. * transition.
  961. */
  962. int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
  963. const u8 *ies, size_t ies_len);
  964. /**
  965. * get_scan_results2 - Fetch the latest scan results
  966. * @priv: private driver interface data
  967. *
  968. * Returns: Allocated buffer of scan results (caller is responsible for
  969. * freeing the data structure) on success, NULL on failure
  970. */
  971. struct wpa_scan_results * (*get_scan_results2)(void *priv);
  972. /**
  973. * set_country - Set country
  974. * @priv: Private driver interface data
  975. * @alpha2: country to which to switch to
  976. * Returns: 0 on success, -1 on failure
  977. *
  978. * This function is for drivers which support some form
  979. * of setting a regulatory domain.
  980. */
  981. int (*set_country)(void *priv, const char *alpha2);
  982. /**
  983. * global_init - Global driver initialization
  984. * Returns: Pointer to private data (global), %NULL on failure
  985. *
  986. * This optional function is called to initialize the driver wrapper
  987. * for global data, i.e., data that applies to all interfaces. If this
  988. * function is implemented, global_deinit() will also need to be
  989. * implemented to free the private data. The driver will also likely
  990. * use init2() function instead of init() to get the pointer to global
  991. * data available to per-interface initializer.
  992. */
  993. void * (*global_init)(void);
  994. /**
  995. * global_deinit - Global driver deinitialization
  996. * @priv: private driver global data from global_init()
  997. *
  998. * Terminate any global driver related functionality and free the
  999. * global data structure.
  1000. */
  1001. void (*global_deinit)(void *priv);
  1002. /**
  1003. * init2 - Initialize driver interface (with global data)
  1004. * @ctx: context to be used when calling wpa_supplicant functions,
  1005. * e.g., wpa_supplicant_event()
  1006. * @ifname: interface name, e.g., wlan0
  1007. * @global_priv: private driver global data from global_init()
  1008. * Returns: Pointer to private data, %NULL on failure
  1009. *
  1010. * This function can be used instead of init() if the driver wrapper
  1011. * uses global data.
  1012. */
  1013. void * (*init2)(void *ctx, const char *ifname, void *global_priv);
  1014. /**
  1015. * get_interfaces - Get information about available interfaces
  1016. * @global_priv: private driver global data from global_init()
  1017. * Returns: Allocated buffer of interface information (caller is
  1018. * responsible for freeing the data structure) on success, NULL on
  1019. * failure
  1020. */
  1021. struct wpa_interface_info * (*get_interfaces)(void *global_priv);
  1022. /**
  1023. * scan2 - Request the driver to initiate scan
  1024. * @priv: private driver interface data
  1025. * @params: Scan parameters
  1026. *
  1027. * Returns: 0 on success, -1 on failure
  1028. *
  1029. * Once the scan results are ready, the driver should report scan
  1030. * results event for wpa_supplicant which will eventually request the
  1031. * results with wpa_driver_get_scan_results2().
  1032. */
  1033. int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
  1034. /**
  1035. * authenticate - Request driver to authenticate
  1036. * @priv: private driver interface data
  1037. * @params: authentication parameters
  1038. * Returns: 0 on success, -1 on failure
  1039. *
  1040. * This is an optional function that can be used with drivers that
  1041. * support separate authentication and association steps, i.e., when
  1042. * wpa_supplicant can act as the SME. If not implemented, associate()
  1043. * function is expected to take care of IEEE 802.11 authentication,
  1044. * too.
  1045. */
  1046. int (*authenticate)(void *priv,
  1047. struct wpa_driver_auth_params *params);
  1048. /**
  1049. * set_beacon - Set Beacon frame template
  1050. * @iface: Interface name (main interface or virtual BSS)
  1051. * @priv: Private driver interface data
  1052. * @head: Beacon head from IEEE 802.11 header to IEs before TIM IE
  1053. * @head_len: Length of the head buffer in octets
  1054. * @tail: Beacon tail following TIM IE
  1055. * @tail_len: Length of the tail buffer in octets
  1056. * @dtim_period: DTIM period
  1057. * @beacon_int: Beacon interval
  1058. * Returns: 0 on success, -1 on failure
  1059. *
  1060. * This function is used to configure Beacon template for the driver in
  1061. * AP mode. The driver is responsible for building the full Beacon
  1062. * frame by concatenating the head part with TIM IE generated by the
  1063. * driver/firmware and finishing with the tail part.
  1064. */
  1065. int (*set_beacon)(const char *ifname, void *priv,
  1066. const u8 *head, size_t head_len,
  1067. const u8 *tail, size_t tail_len, int dtim_period,
  1068. int beacon_int);
  1069. /**
  1070. * hapd_init - Initialize driver interface (hostapd only)
  1071. * @hapd: Pointer to hostapd context
  1072. * @params: Configuration for the driver wrapper
  1073. * Returns: Pointer to private data, %NULL on failure
  1074. *
  1075. * This function is used instead of init() or init2() when the driver
  1076. * wrapper is used withh hostapd.
  1077. */
  1078. void * (*hapd_init)(struct hostapd_data *hapd,
  1079. struct wpa_init_params *params);
  1080. /**
  1081. * hapd_deinit - Deinitialize driver interface (hostapd only)
  1082. * @priv: Private driver interface data from hapd_init()
  1083. */
  1084. void (*hapd_deinit)(void *priv);
  1085. /**
  1086. * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
  1087. * @priv: Private driver interface data
  1088. * @params: BSS parameters
  1089. * Returns: 0 on success, -1 on failure
  1090. *
  1091. * This is an optional function to configure the kernel driver to
  1092. * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
  1093. * can be left undefined (set to %NULL) if IEEE 802.1X support is
  1094. * always enabled and the driver uses set_beacon() to set WPA/RSN IE
  1095. * for Beacon frames.
  1096. */
  1097. int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
  1098. /**
  1099. * set_privacy - Enable/disable privacy (AP only)
  1100. * @priv: Private driver interface data
  1101. * @enabled: 1 = privacy enabled, 0 = disabled
  1102. * Returns: 0 on success, -1 on failure
  1103. *
  1104. * This is an optional function to configure privacy field in the
  1105. * kernel driver for Beacon frames. This can be left undefined (set to
  1106. * %NULL) if the driver uses the Beacon template from set_beacon().
  1107. */
  1108. int (*set_privacy)(const char *ifname, void *priv, int enabled);
  1109. /**
  1110. * get_seqnum - Fetch the current TSC/packet number (AP only)
  1111. * @ifname: The interface name (main or virtual)
  1112. * @priv: Private driver interface data
  1113. * @addr: MAC address of the station or %NULL for group keys
  1114. * @idx: Key index
  1115. * @seq: Buffer for returning the latest used TSC/packet number
  1116. * Returns: 0 on success, -1 on failure
  1117. *
  1118. * This function is used to fetch the last used TSC/packet number for
  1119. * a TKIP, CCMP, or BIP/IGTK key. It is mainly used with group keys, so
  1120. * there is no strict requirement on implementing support for unicast
  1121. * keys (i.e., addr != %NULL).
  1122. */
  1123. int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
  1124. int idx, u8 *seq);
  1125. /**
  1126. * flush - Flush all association stations (AP only)
  1127. * @priv: Private driver interface data
  1128. * Returns: 0 on success, -1 on failure
  1129. *
  1130. * This function requests the driver to disassociate all associated
  1131. * stations. This function does not need to be implemented if the
  1132. * driver does not process association frames internally.
  1133. */
  1134. int (*flush)(void *priv);
  1135. /**
  1136. * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
  1137. * @ifname: The interface name (main or virtual BSS)
  1138. * @priv: Private driver interface data
  1139. * @elem: Information elements
  1140. * @elem_len: Length of the elem buffer in octets
  1141. * Returns: 0 on success, -1 on failure
  1142. *
  1143. * This is an optional function to add information elements in the
  1144. * kernel driver for Beacon and Probe Response frames. This can be left
  1145. * undefined (set to %NULL) if the driver uses the Beacon template from
  1146. * set_beacon().
  1147. */
  1148. int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
  1149. size_t elem_len);
  1150. /**
  1151. * read_sta_data - Fetch station data (AP only)
  1152. * @priv: Private driver interface data
  1153. * @data: Buffer for returning station information
  1154. * @addr: MAC address of the station
  1155. * Returns: 0 on success, -1 on failure
  1156. */
  1157. int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
  1158. const u8 *addr);
  1159. /**
  1160. * hapd_send_eapol - Send an EAPOL packet (AP only)
  1161. * @priv: private driver interface data
  1162. * @addr: Destination MAC address
  1163. * @data: EAPOL packet starting with IEEE 802.1X header
  1164. * @data_len: Length of the EAPOL packet in octets
  1165. * @encrypt: Whether the frame should be encrypted
  1166. * @own_addr: Source MAC address
  1167. *
  1168. * Returns: 0 on success, -1 on failure
  1169. */
  1170. int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
  1171. size_t data_len, int encrypt,
  1172. const u8 *own_addr);
  1173. /**
  1174. * sta_deauth - Deauthenticate a station (AP only)
  1175. * @priv: Private driver interface data
  1176. * @own_addr: Source address and BSSID for the Deauthentication frame
  1177. * @addr: MAC address of the station to deauthenticate
  1178. * @reason: Reason code for the Deauthentiation frame
  1179. * Returns: 0 on success, -1 on failure
  1180. *
  1181. * This function requests a specific station to be deauthenticated and
  1182. * a Deauthentication frame to be sent to it.
  1183. */
  1184. int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
  1185. int reason);
  1186. /**
  1187. * sta_disassoc - Disassociate a station (AP only)
  1188. * @priv: Private driver interface data
  1189. * @own_addr: Source address and BSSID for the Disassociation frame
  1190. * @addr: MAC address of the station to disassociate
  1191. * @reason: Reason code for the Disassociation frame
  1192. * Returns: 0 on success, -1 on failure
  1193. *
  1194. * This function requests a specific station to be disassociated and
  1195. * a Disassociation frame to be sent to it.
  1196. */
  1197. int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
  1198. int reason);
  1199. /**
  1200. * sta_remove - Remove a station entry (AP only)
  1201. * @priv: Private driver interface data
  1202. * @addr: MAC address of the station to be removed
  1203. * Returns: 0 on success, -1 on failure
  1204. */
  1205. int (*sta_remove)(void *priv, const u8 *addr);
  1206. /**
  1207. * hapd_get_ssid - Get the current SSID (AP only)
  1208. * @ifname: Interface (master or virtual BSS)
  1209. * @priv: Private driver interface data
  1210. * @buf: Buffer for returning the SSID
  1211. * @len: Maximum length of the buffer
  1212. * Returns: Length of the SSID on success, -1 on failure
  1213. *
  1214. * This function need not be implemented if the driver uses Beacon
  1215. * template from set_beacon() and does not reply to Probe Request
  1216. * frames.
  1217. */
  1218. int (*hapd_get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
  1219. /**
  1220. * hapd_set_ssid - Set SSID (AP only)
  1221. * @ifname: Interface (master or virtual BSS)
  1222. * @priv: Private driver interface data
  1223. * @buf: SSID
  1224. * @len: Length of the SSID in octets
  1225. * Returns: 0 on success, -1 on failure
  1226. */
  1227. int (*hapd_set_ssid)(const char *ifname, void *priv, const u8 *buf,
  1228. int len);
  1229. /**
  1230. * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
  1231. * @priv: Private driver interface data
  1232. * @enabled: 1 = countermeasures enabled, 0 = disabled
  1233. * Returns: 0 on success, -1 on failure
  1234. *
  1235. * This need not be implemented if the driver does not take care of
  1236. * association processing.
  1237. */
  1238. int (*hapd_set_countermeasures)(void *priv, int enabled);
  1239. /**
  1240. * sta_add - Add a station entry
  1241. * @ifname: Interface (master or virtual)
  1242. * @priv: Private driver interface data
  1243. * @params: Station parameters
  1244. * Returns: 0 on success, -1 on failure
  1245. *
  1246. * This function is used to add a station entry to the driver once the
  1247. * station has completed association. This is only used if the driver
  1248. * does not take care of association processing.
  1249. */
  1250. int (*sta_add)(const char *ifname, void *priv,
  1251. struct hostapd_sta_add_params *params);
  1252. /**
  1253. * get_inact_sec - Get station inactivity duration (AP only)
  1254. * @priv: Private driver interface data
  1255. * @addr: Station address
  1256. * Returns: Number of seconds station has been inactive, -1 on failure
  1257. */
  1258. int (*get_inact_sec)(void *priv, const u8 *addr);
  1259. /**
  1260. * sta_clear_stats - Clear station statistics (AP only)
  1261. * @priv: Private driver interface data
  1262. * @addr: Station address
  1263. * Returns: 0 on success, -1 on failure
  1264. */
  1265. int (*sta_clear_stats)(void *priv, const u8 *addr);
  1266. /**
  1267. * set_freq - Set channel/frequency (AP only)
  1268. * @priv: Private driver interface data
  1269. * @freq: Channel parameters
  1270. * Returns: 0 on success, -1 on failure
  1271. */
  1272. int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
  1273. /**
  1274. * set_rts - Set RTS threshold
  1275. * @priv: Private driver interface data
  1276. * @rts: RTS threshold in octets
  1277. * Returns: 0 on success, -1 on failure
  1278. */
  1279. int (*set_rts)(void *priv, int rts);
  1280. /**
  1281. * set_frag - Set fragmentation threshold
  1282. * @priv: Private driver interface data
  1283. * @frag: Fragmentation threshold in octets
  1284. * Returns: 0 on success, -1 on failure
  1285. */
  1286. int (*set_frag)(void *priv, int frag);
  1287. /**
  1288. * sta_set_flags - Set station flags (AP only)
  1289. * @ifname: Interface name (for multi-SSID/VLAN support)
  1290. * @priv: Private driver interface data
  1291. * @addr: Station address
  1292. * @total_flags: Bitmap of all WPA_STA_* flags currently set
  1293. * @flags_or: Bitmap of WPA_STA_* flags to add
  1294. * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
  1295. * Returns: 0 on success, -1 on failure
  1296. */
  1297. int (*sta_set_flags)(const char *ifname, void *priv, const u8 *addr,
  1298. int total_flags, int flags_or, int flags_and);
  1299. /**
  1300. * set_rate_sets - Set supported and basic rate sets (AP only)
  1301. * @priv: Private driver interface data
  1302. * @supp_rates: -1 terminated array of supported rates in 100 kbps
  1303. * @basic_rates: -1 terminated array of basic rates in 100 kbps
  1304. * @mode: hardware mode (HOSTAPD_MODE_*)
  1305. * Returns: 0 on success, -1 on failure
  1306. */
  1307. int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
  1308. int mode);
  1309. /**
  1310. * set_cts_protect - Set CTS protection mode (AP only)
  1311. * @priv: Private driver interface data
  1312. * @value: Whether CTS protection is enabled
  1313. * Returns: 0 on success, -1 on failure
  1314. */
  1315. int (*set_cts_protect)(void *priv, int value);
  1316. /**
  1317. * set_preamble - Set preamble mode (AP only)
  1318. * @priv: Private driver interface data
  1319. * @value: Whether short preamble is enabled
  1320. * Returns: 0 on success, -1 on failure
  1321. */
  1322. int (*set_preamble)(void *priv, int value);
  1323. /**
  1324. * set_short_slot_time - Set short slot time (AP only)
  1325. * @priv: Private driver interface data
  1326. * @value: Whether short slot time is enabled
  1327. * Returns: 0 on success, -1 on failure
  1328. */
  1329. int (*set_short_slot_time)(void *priv, int value);
  1330. /**
  1331. * set_tx_queue_params - Set TX queue parameters
  1332. * @priv: Private driver interface data
  1333. * @queue: Queue number
  1334. * @aifs: AIFS
  1335. * @cw_min: cwMin
  1336. * @cw_max: cwMax
  1337. * @burst_time: Maximum length for bursting in 0.1 msec units
  1338. */
  1339. int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
  1340. int cw_max, int burst_time);
  1341. /**
  1342. * valid_bss_mask - Validate BSSID mask
  1343. * @priv: Private driver interface data
  1344. * @addr: Address
  1345. * @mask: Mask
  1346. * Returns: 0 if mask is valid, -1 if mask is not valid, 1 if mask can
  1347. * be used, but the main interface address must be the first address in
  1348. * the block if mask is applied
  1349. */
  1350. int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
  1351. /**
  1352. * if_add - Add a virtual interface
  1353. * @iface: Parent interface name
  1354. * @priv: Private driver interface data
  1355. * @type: Interface type
  1356. * @ifname: Interface name for the new virtual interface
  1357. * @addr: Local address to use for the interface or %NULL to use the
  1358. * parent interface address
  1359. * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
  1360. * @drv_priv: Pointer for overwriting the driver context or %NULL if
  1361. * not allowed (applies only to %WPA_IF_AP_BSS type)
  1362. * Returns: 0 on success, -1 on failure
  1363. */
  1364. int (*if_add)(const char *iface, void *priv,
  1365. enum wpa_driver_if_type type, const char *ifname,
  1366. const u8 *addr, void *bss_ctx, void **drv_priv);
  1367. /**
  1368. * if_remove - Remove a virtual interface
  1369. * @priv: Private driver interface data
  1370. * @type: Interface type
  1371. * @ifname: Interface name of the virtual interface to be removed
  1372. * Returns: 0 on success, -1 on failure
  1373. */
  1374. int (*if_remove)(void *priv, enum wpa_driver_if_type type,
  1375. const char *ifname);
  1376. /**
  1377. * set_sta_vlan - Bind a station into a specific interface (AP only)
  1378. * @priv: Private driver interface data
  1379. * @ifname: Interface (main or virtual BSS or VLAN)
  1380. * @addr: MAC address of the associated station
  1381. * @vlan_id: VLAN ID
  1382. * Returns: 0 on success, -1 on failure
  1383. *
  1384. * This function is used to bind a station to a specific virtual
  1385. * interface. It is only used if when virtual interfaces are supported,
  1386. * e.g., to assign stations to different VLAN interfaces based on
  1387. * information from a RADIUS server. This allows separate broadcast
  1388. * domains to be used with a single BSS.
  1389. */
  1390. int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
  1391. int vlan_id);
  1392. /**
  1393. * commit - Optional commit changes handler (AP only)
  1394. * @priv: driver private data
  1395. * Returns: 0 on success, -1 on failure
  1396. *
  1397. * This optional handler function can be registered if the driver
  1398. * interface implementation needs to commit changes (e.g., by setting
  1399. * network interface up) at the end of initial configuration. If set,
  1400. * this handler will be called after initial setup has been completed.
  1401. */
  1402. int (*commit)(void *priv);
  1403. /**
  1404. * send_ether - Send an ethernet packet (AP only)
  1405. * @priv: private driver interface data
  1406. * @dst: Destination MAC address
  1407. * @src: Source MAC address
  1408. * @proto: Ethertype
  1409. * @data: EAPOL packet starting with IEEE 802.1X header
  1410. * @data_len: Length of the EAPOL packet in octets
  1411. * Returns: 0 on success, -1 on failure
  1412. */
  1413. int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
  1414. const u8 *data, size_t data_len);
  1415. /**
  1416. * set_radius_acl_auth - Notification of RADIUS ACL change
  1417. * @priv: Private driver interface data
  1418. * @mac: MAC address of the station
  1419. * @accepted: Whether the station was accepted
  1420. * @session_timeout: Session timeout for the station
  1421. * Returns: 0 on success, -1 on failure
  1422. */
  1423. int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
  1424. u32 session_timeout);
  1425. /**
  1426. * set_radius_acl_expire - Notification of RADIUS ACL expiration
  1427. * @priv: Private driver interface data
  1428. * @mac: MAC address of the station
  1429. * Returns: 0 on success, -1 on failure
  1430. */
  1431. int (*set_radius_acl_expire)(void *priv, const u8 *mac);
  1432. /**
  1433. * set_ht_params - Set HT parameters (AP only)
  1434. * @ifname: The interface name (main or virtual BSS)
  1435. * @priv: Private driver interface data
  1436. * @ht_capab: HT Capabilities IE
  1437. * @ht_capab_len: Length of ht_capab in octets
  1438. * @ht_oper: HT Operation IE
  1439. * @ht_oper_len: Length of ht_oper in octets
  1440. * Returns: 0 on success, -1 on failure
  1441. */
  1442. int (*set_ht_params)(const char *ifname, void *priv,
  1443. const u8 *ht_capab, size_t ht_capab_len,
  1444. const u8 *ht_oper, size_t ht_oper_len);
  1445. /**
  1446. * set_ap_wps_ie - Add WPS IE into Beacon/Probe Response frames (AP)
  1447. * @ifname: The interface name (main or virtual BSS)
  1448. * @priv: Private driver interface data
  1449. * @beacon: WPS IE for Beacon frames
  1450. * @proberesp: WPS IE for Probe Response frames
  1451. * Returns: 0 on success, -1 on failure
  1452. *
  1453. * This is an optional function to add WPS IE in the kernel driver for
  1454. * Beacon and Probe Response frames. This can be left undefined (set
  1455. * to %NULL) if the driver uses the Beacon template from set_beacon()
  1456. * and does not process Probe Request frames.
  1457. */
  1458. int (*set_ap_wps_ie)(const char *ifname, void *priv,
  1459. const struct wpabuf *beacon,
  1460. const struct wpabuf *proberesp);
  1461. /**
  1462. * set_supp_port - Set IEEE 802.1X Supplicant Port status
  1463. * @priv: Private driver interface data
  1464. * @authorized: Whether the port is authorized
  1465. * Returns: 0 on success, -1 on failure
  1466. */
  1467. int (*set_supp_port)(void *priv, int authorized);
  1468. /**
  1469. * set_wds_sta - Bind a station into a 4-address WDS (AP only)
  1470. * @priv: Private driver interface data
  1471. * @addr: MAC address of the associated station
  1472. * @aid: Association ID
  1473. * @val: 1 = bind to 4-address WDS; 0 = unbind
  1474. * Returns: 0 on success, -1 on failure
  1475. */
  1476. int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val);
  1477. /**
  1478. * send_action - Transmit an Action frame
  1479. * @priv: Private driver interface data
  1480. * @freq: Frequency (in MHz) of the channel
  1481. * @dst: Destination MAC address (Address 1)
  1482. * @src: Source MAC address (Address 2)
  1483. * @bssid: BSSID (Address 3)
  1484. * @data: Frame body
  1485. * @data_len: data length in octets
  1486. * Returns: 0 on success, -1 on failure
  1487. *
  1488. * This command can be used to request the driver to transmit an action
  1489. * frame to the specified destination. If a remain-on-channel duration
  1490. * is in progress, the frame is transmitted on that channel. Otherwise,
  1491. * the frame is transmitted on the current operational channel if in
  1492. * associated state in station mode or if operating as an AP. If none
  1493. * of these conditions is in effect, send_action() cannot be used.
  1494. */
  1495. int (*send_action)(void *priv, unsigned int freq,
  1496. const u8 *dst, const u8 *src, const u8 *bssid,
  1497. const u8 *data, size_t data_len);
  1498. /**
  1499. * alloc_interface_addr - Allocate a virtual interface address
  1500. * @priv: Private driver interface data
  1501. * @addr: Buffer for returning the address
  1502. * @ifname: Buffer for returning interface name (if needed)
  1503. * Returns: 0 on success, -1 on failure
  1504. *
  1505. * This command pre-allocates an interface address for a new virtual
  1506. * interface. This can be used before creating a virtual interface if
  1507. * the interface mode (e.g., AP vs. station) is not yet known, but the
  1508. * address of the virtual interface is already needed. This helps with
  1509. * drivers that cannot change interface mode without destroying and
  1510. * re-creating the interface. If the driver requires a specific
  1511. * interface name to be used, the ifname buffer (up to IFNAMSIZ
  1512. * characters) will be used to indicate which name must be used for
  1513. * this virtual interface.
  1514. *
  1515. * The allocated address can be used in a if_add() call to request a
  1516. * specific bssid.
  1517. */
  1518. int (*alloc_interface_addr)(void *priv, u8 *addr, char *ifname);
  1519. /**
  1520. * release_interface_addr - Release a virtual interface address
  1521. * @priv: Private driver interface data
  1522. * @addr: Address to be freed from alloc_interface_addr()
  1523. *
  1524. * This command is used to release a virtual interface address that was
  1525. * allocated with alloc_interface_addr(), but has not yet been used
  1526. * with if_add() to actually create the interface. This allows the
  1527. * driver to release the pending allocation for a new interface.
  1528. */
  1529. void (*release_interface_addr)(void *priv, const u8 *addr);
  1530. /**
  1531. * remain_on_channel - Remain awake on a channel
  1532. * @priv: Private driver interface data
  1533. * @freq: Frequency (in MHz) of the channel
  1534. * @duration: Duration in milliseconds
  1535. * Returns: 0 on success, -1 on failure
  1536. *
  1537. * This command is used to request the driver to remain awake on the
  1538. * specified channel for the specified duration and report received
  1539. * Action frames with EVENT_RX_ACTION events. Optionally, received
  1540. * Probe Request frames may also be requested to be reported by calling
  1541. * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
  1542. *
  1543. * The driver may not be at the requested channel when this function
  1544. * returns, i.e., the return code is only indicating whether the
  1545. * request was accepted. The caller will need to wait until the
  1546. * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
  1547. * completed the channel change. This may take some time due to other
  1548. * need for the radio and the caller should be prepared to timing out
  1549. * its wait since there are no guarantees on when this request can be
  1550. * executed.
  1551. */
  1552. int (*remain_on_channel)(void *priv, unsigned int freq,
  1553. unsigned int duration);
  1554. /**
  1555. * cancel_remain_on_channel - Cancel remain-on-channel operation
  1556. * @priv: Private driver interface data
  1557. *
  1558. * This command can be used to cancel a remain-on-channel operation
  1559. * before its originally requested duration has passed. This could be
  1560. * used, e.g., when remain_on_channel() is used to request extra time
  1561. * to receive a response to an Action frame and the response is
  1562. * received when there is still unneeded time remaining on the
  1563. * remain-on-channel operation.
  1564. */
  1565. int (*cancel_remain_on_channel)(void *priv);
  1566. /**
  1567. * probe_req_report - Request Probe Request frames to be indicated
  1568. * @priv: Private driver interface data
  1569. * @report: Whether to report received Probe Request frames
  1570. * Returns: 0 on success, -1 on failure (or if not supported)
  1571. *
  1572. * This command can be used to request the driver to indicate when
  1573. * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
  1574. * Since this operation may require extra resources, e.g., due to less
  1575. * optimal hardware/firmware RX filtering, many drivers may disable
  1576. * Probe Request reporting at least in station mode. This command is
  1577. * used to notify the driver when the Probe Request frames need to be
  1578. * reported, e.g., during remain-on-channel operations.
  1579. */
  1580. int (*probe_req_report)(void *priv, int report);
  1581. /**
  1582. * disable_11b_rates - Set whether IEEE 802.11b rates are used for TX
  1583. * @priv: Private driver interface data
  1584. * @disabled: Whether IEEE 802.11b rates are disabled
  1585. * Returns: 0 on success, -1 on failure (or if not supported)
  1586. *
  1587. * This command is used to disable IEEE 802.11b rates (1, 2, 5.5, and
  1588. * 11 Mbps) as TX rates for data and management frames. This can be
  1589. * used to optimize channel use when there is no need to support IEEE
  1590. * 802.11b-only devices.
  1591. */
  1592. int (*disable_11b_rates)(void *priv, int disabled);
  1593. /**
  1594. * deinit_ap - Deinitialize AP mode
  1595. * @priv: Private driver interface data
  1596. * Returns: 0 on success, -1 on failure (or if not supported)
  1597. *
  1598. * This optional function can be used to disable AP mode related
  1599. * configuration and change the driver mode to station mode to allow
  1600. * normal station operations like scanning to be completed.
  1601. */
  1602. int (*deinit_ap)(void *priv);
  1603. /**
  1604. * suspend - Notification on system suspend/hibernate event
  1605. * @priv: Private driver interface data
  1606. */
  1607. void (*suspend)(void *priv);
  1608. /**
  1609. * resume - Notification on system resume/thaw event
  1610. * @priv: Private driver interface data
  1611. */
  1612. void (*resume)(void *priv);
  1613. };
  1614. /**
  1615. * enum wpa_event_type - Event type for wpa_supplicant_event() calls
  1616. */
  1617. enum wpa_event_type {
  1618. /**
  1619. * EVENT_ASSOC - Association completed
  1620. *
  1621. * This event needs to be delivered when the driver completes IEEE
  1622. * 802.11 association or reassociation successfully.
  1623. * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
  1624. * after this event has been generated. In addition, optional
  1625. * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
  1626. * more information about the association. If the driver interface gets
  1627. * both of these events at the same time, it can also include the
  1628. * assoc_info data in EVENT_ASSOC call.
  1629. */
  1630. EVENT_ASSOC,
  1631. /**
  1632. * EVENT_DISASSOC - Association lost
  1633. *
  1634. * This event should be called when association is lost either due to
  1635. * receiving deauthenticate or disassociate frame from the AP or when
  1636. * sending either of these frames to the current AP. If the driver
  1637. * supports separate deauthentication event, EVENT_DISASSOC should only
  1638. * be used for disassociation and EVENT_DEAUTH for deauthentication.
  1639. * In AP mode, union wpa_event_data::disassoc_info is required.
  1640. */
  1641. EVENT_DISASSOC,
  1642. /**
  1643. * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
  1644. *
  1645. * This event must be delivered when a Michael MIC error is detected by
  1646. * the local driver. Additional data for event processing is
  1647. * provided with union wpa_event_data::michael_mic_failure. This
  1648. * information is used to request new encyption key and to initiate
  1649. * TKIP countermeasures if needed.
  1650. */
  1651. EVENT_MICHAEL_MIC_FAILURE,
  1652. /**
  1653. * EVENT_SCAN_RESULTS - Scan results available
  1654. *
  1655. * This event must be called whenever scan results are available to be
  1656. * fetched with struct wpa_driver_ops::get_scan_results(). This event
  1657. * is expected to be used some time after struct wpa_driver_ops::scan()
  1658. * is called. If the driver provides an unsolicited event when the scan
  1659. * has been completed, this event can be used to trigger
  1660. * EVENT_SCAN_RESULTS call. If such event is not available from the
  1661. * driver, the driver wrapper code is expected to use a registered
  1662. * timeout to generate EVENT_SCAN_RESULTS call after the time that the
  1663. * scan is expected to be completed. Optional information about
  1664. * completed scan can be provided with union wpa_event_data::scan_info.
  1665. */
  1666. EVENT_SCAN_RESULTS,
  1667. /**
  1668. * EVENT_ASSOCINFO - Report optional extra information for association
  1669. *
  1670. * This event can be used to report extra association information for
  1671. * EVENT_ASSOC processing. This extra information includes IEs from
  1672. * association frames and Beacon/Probe Response frames in union
  1673. * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
  1674. * EVENT_ASSOC. Alternatively, the driver interface can include
  1675. * assoc_info data in the EVENT_ASSOC call if it has all the
  1676. * information available at the same point.
  1677. */
  1678. EVENT_ASSOCINFO,
  1679. /**
  1680. * EVENT_INTERFACE_STATUS - Report interface status changes
  1681. *
  1682. * This optional event can be used to report changes in interface
  1683. * status (interface added/removed) using union
  1684. * wpa_event_data::interface_status. This can be used to trigger
  1685. * wpa_supplicant to stop and re-start processing for the interface,
  1686. * e.g., when a cardbus card is ejected/inserted.
  1687. */
  1688. EVENT_INTERFACE_STATUS,
  1689. /**
  1690. * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
  1691. *
  1692. * This event can be used to inform wpa_supplicant about candidates for
  1693. * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
  1694. * for scan request (ap_scan=2 mode), this event is required for
  1695. * pre-authentication. If wpa_supplicant is performing scan request
  1696. * (ap_scan=1), this event is optional since scan results can be used
  1697. * to add pre-authentication candidates. union
  1698. * wpa_event_data::pmkid_candidate is used to report the BSSID of the
  1699. * candidate and priority of the candidate, e.g., based on the signal
  1700. * strength, in order to try to pre-authenticate first with candidates
  1701. * that are most likely targets for re-association.
  1702. *
  1703. * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
  1704. * on the candidate list. In addition, it can be called for the current
  1705. * AP and APs that have existing PMKSA cache entries. wpa_supplicant
  1706. * will automatically skip pre-authentication in cases where a valid
  1707. * PMKSA exists. When more than one candidate exists, this event should
  1708. * be generated once for each candidate.
  1709. *
  1710. * Driver will be notified about successful pre-authentication with
  1711. * struct wpa_driver_ops::add_pmkid() calls.
  1712. */
  1713. EVENT_PMKID_CANDIDATE,
  1714. /**
  1715. * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
  1716. *
  1717. * This event can be used to inform wpa_supplicant about desire to set
  1718. * up secure direct link connection between two stations as defined in
  1719. * IEEE 802.11e with a new PeerKey mechanism that replaced the original
  1720. * STAKey negotiation. The caller will need to set peer address for the
  1721. * event.
  1722. */
  1723. EVENT_STKSTART,
  1724. /**
  1725. * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
  1726. *
  1727. * The driver is expected to report the received FT IEs from
  1728. * FT authentication sequence from the AP. The FT IEs are included in
  1729. * the extra information in union wpa_event_data::ft_ies.
  1730. */
  1731. EVENT_FT_RESPONSE,
  1732. /**
  1733. * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
  1734. *
  1735. * The driver can use this event to inform wpa_supplicant about a STA
  1736. * in an IBSS with which protected frames could be exchanged. This
  1737. * event starts RSN authentication with the other STA to authenticate
  1738. * the STA and set up encryption keys with it.
  1739. */
  1740. EVENT_IBSS_RSN_START,
  1741. /**
  1742. * EVENT_AUTH - Authentication result
  1743. *
  1744. * This event should be called when authentication attempt has been
  1745. * completed. This is only used if the driver supports separate
  1746. * authentication step (struct wpa_driver_ops::authenticate).
  1747. * Information about authentication result is included in
  1748. * union wpa_event_data::auth.
  1749. */
  1750. EVENT_AUTH,
  1751. /**
  1752. * EVENT_DEAUTH - Authentication lost
  1753. *
  1754. * This event should be called when authentication is lost either due
  1755. * to receiving deauthenticate frame from the AP or when sending that
  1756. * frame to the current AP.
  1757. * In AP mode, union wpa_event_data::deauth_info is required.
  1758. */
  1759. EVENT_DEAUTH,
  1760. /**
  1761. * EVENT_ASSOC_REJECT - Association rejected
  1762. *
  1763. * This event should be called when (re)association attempt has been
  1764. * rejected by the AP. Information about authentication result is
  1765. * included in union wpa_event_data::assoc_reject.
  1766. */
  1767. EVENT_ASSOC_REJECT,
  1768. /**
  1769. * EVENT_AUTH_TIMED_OUT - Authentication timed out
  1770. */
  1771. EVENT_AUTH_TIMED_OUT,
  1772. /**
  1773. * EVENT_ASSOC_TIMED_OUT - Association timed out
  1774. */
  1775. EVENT_ASSOC_TIMED_OUT,
  1776. /**
  1777. * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
  1778. */
  1779. EVENT_FT_RRB_RX,
  1780. /**
  1781. * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
  1782. */
  1783. EVENT_WPS_BUTTON_PUSHED,
  1784. /**
  1785. * EVENT_TX_STATUS - Report TX status
  1786. */
  1787. EVENT_TX_STATUS,
  1788. /**
  1789. * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
  1790. */
  1791. EVENT_RX_FROM_UNKNOWN,
  1792. /**
  1793. * EVENT_RX_MGMT - Report RX of a management frame
  1794. */
  1795. EVENT_RX_MGMT,
  1796. /**
  1797. * EVENT_RX_ACTION - Action frame received
  1798. *
  1799. * This event is used to indicate when an Action frame has been
  1800. * received. Information about the received frame is included in
  1801. * union wpa_event_data::rx_action.
  1802. */
  1803. EVENT_RX_ACTION,
  1804. /**
  1805. * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
  1806. *
  1807. * This event is used to indicate when the driver has started the
  1808. * requested remain-on-channel duration. Information about the
  1809. * operation is included in union wpa_event_data::remain_on_channel.
  1810. */
  1811. EVENT_REMAIN_ON_CHANNEL,
  1812. /**
  1813. * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
  1814. *
  1815. * This event is used to indicate when the driver has completed
  1816. * remain-on-channel duration, i.e., may noot be available on the
  1817. * requested channel anymore. Information about the
  1818. * operation is included in union wpa_event_data::remain_on_channel.
  1819. */
  1820. EVENT_CANCEL_REMAIN_ON_CHANNEL,
  1821. /**
  1822. * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
  1823. *
  1824. * This event is used only by driver_test.c and userspace MLME.
  1825. */
  1826. EVENT_MLME_RX,
  1827. /**
  1828. * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
  1829. *
  1830. * This event is used to indicate when a Probe Request frame has been
  1831. * received. Information about the received frame is included in
  1832. * union wpa_event_data::rx_probe_req. The driver is required to report
  1833. * these events only after successfully completed probe_req_report()
  1834. * commands to request the events (i.e., report parameter is non-zero)
  1835. * in station mode. In AP mode, Probe Request frames should always be
  1836. * reported.
  1837. */
  1838. EVENT_RX_PROBE_REQ,
  1839. /**
  1840. * EVENT_NEW_STA - New wired device noticed
  1841. *
  1842. * This event is used to indicate that a new device has been detected
  1843. * in a network that does not use association-like functionality (i.e.,
  1844. * mainly wired Ethernet). This can be used to start EAPOL
  1845. * authenticator when receiving a frame from a device. The address of
  1846. * the device is included in union wpa_event_data::new_sta.
  1847. */
  1848. EVENT_NEW_STA,
  1849. /**
  1850. * EVENT_EAPOL_RX - Report received EAPOL frame
  1851. *
  1852. * When in AP mode with hostapd, this event is required to be used to
  1853. * deliver the receive EAPOL frames from the driver. With
  1854. * %wpa_supplicant, this event is used only if the send_eapol() handler
  1855. * is used to override the use of l2_packet for EAPOL frame TX.
  1856. */
  1857. EVENT_EAPOL_RX
  1858. };
  1859. /**
  1860. * union wpa_event_data - Additional data for wpa_supplicant_event() calls
  1861. */
  1862. union wpa_event_data {
  1863. /**
  1864. * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
  1865. *
  1866. * This structure is optional for EVENT_ASSOC calls and required for
  1867. * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
  1868. * driver interface does not need to generate separate EVENT_ASSOCINFO
  1869. * calls.
  1870. */
  1871. struct assoc_info {
  1872. /**
  1873. * req_ies - (Re)Association Request IEs
  1874. *
  1875. * If the driver generates WPA/RSN IE, this event data must be
  1876. * returned for WPA handshake to have needed information. If
  1877. * wpa_supplicant-generated WPA/RSN IE is used, this
  1878. * information event is optional.
  1879. *
  1880. * This should start with the first IE (fixed fields before IEs
  1881. * are not included).
  1882. */
  1883. const u8 *req_ies;
  1884. /**
  1885. * req_ies_len - Length of req_ies in bytes
  1886. */
  1887. size_t req_ies_len;
  1888. /**
  1889. * resp_ies - (Re)Association Response IEs
  1890. *
  1891. * Optional association data from the driver. This data is not
  1892. * required WPA, but may be useful for some protocols and as
  1893. * such, should be reported if this is available to the driver
  1894. * interface.
  1895. *
  1896. * This should start with the first IE (fixed fields before IEs
  1897. * are not included).
  1898. */
  1899. const u8 *resp_ies;
  1900. /**
  1901. * resp_ies_len - Length of resp_ies in bytes
  1902. */
  1903. size_t resp_ies_len;
  1904. /**
  1905. * beacon_ies - Beacon or Probe Response IEs
  1906. *
  1907. * Optional Beacon/ProbeResp data: IEs included in Beacon or
  1908. * Probe Response frames from the current AP (i.e., the one
  1909. * that the client just associated with). This information is
  1910. * used to update WPA/RSN IE for the AP. If this field is not
  1911. * set, the results from previous scan will be used. If no
  1912. * data for the new AP is found, scan results will be requested
  1913. * again (without scan request). At this point, the driver is
  1914. * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
  1915. * used).
  1916. *
  1917. * This should start with the first IE (fixed fields before IEs
  1918. * are not included).
  1919. */
  1920. const u8 *beacon_ies;
  1921. /**
  1922. * beacon_ies_len - Length of beacon_ies */
  1923. size_t beacon_ies_len;
  1924. /**
  1925. * freq - Frequency of the operational channel in MHz
  1926. */
  1927. unsigned int freq;
  1928. /**
  1929. * addr - Station address (for AP mode)
  1930. */
  1931. const u8 *addr;
  1932. } assoc_info;
  1933. /**
  1934. * struct disassoc_info - Data for EVENT_DISASSOC events
  1935. */
  1936. struct disassoc_info {
  1937. /**
  1938. * addr - Station address (for AP mode)
  1939. */
  1940. const u8 *addr;
  1941. } disassoc_info;
  1942. /**
  1943. * struct deauth_info - Data for EVENT_DEAUTH events
  1944. */
  1945. struct deauth_info {
  1946. /**
  1947. * addr - Station address (for AP mode)
  1948. */
  1949. const u8 *addr;
  1950. } deauth_info;
  1951. /**
  1952. * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
  1953. */
  1954. struct michael_mic_failure {
  1955. int unicast;
  1956. const u8 *src;
  1957. } michael_mic_failure;
  1958. /**
  1959. * struct interface_status - Data for EVENT_INTERFACE_STATUS
  1960. */
  1961. struct interface_status {
  1962. char ifname[100];
  1963. enum {
  1964. EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
  1965. } ievent;
  1966. } interface_status;
  1967. /**
  1968. * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
  1969. */
  1970. struct pmkid_candidate {
  1971. /** BSSID of the PMKID candidate */
  1972. u8 bssid[ETH_ALEN];
  1973. /** Smaller the index, higher the priority */
  1974. int index;
  1975. /** Whether RSN IE includes pre-authenticate flag */
  1976. int preauth;
  1977. } pmkid_candidate;
  1978. /**
  1979. * struct stkstart - Data for EVENT_STKSTART
  1980. */
  1981. struct stkstart {
  1982. u8 peer[ETH_ALEN];
  1983. } stkstart;
  1984. /**
  1985. * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
  1986. *
  1987. * During FT (IEEE 802.11r) authentication sequence, the driver is
  1988. * expected to use this event to report received FT IEs (MDIE, FTIE,
  1989. * RSN IE, TIE, possible resource request) to the supplicant. The FT
  1990. * IEs for the next message will be delivered through the
  1991. * struct wpa_driver_ops::update_ft_ies() callback.
  1992. */
  1993. struct ft_ies {
  1994. const u8 *ies;
  1995. size_t ies_len;
  1996. int ft_action;
  1997. u8 target_ap[ETH_ALEN];
  1998. /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
  1999. const u8 *ric_ies;
  2000. /** Length of ric_ies buffer in octets */
  2001. size_t ric_ies_len;
  2002. } ft_ies;
  2003. /**
  2004. * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
  2005. */
  2006. struct ibss_rsn_start {
  2007. u8 peer[ETH_ALEN];
  2008. } ibss_rsn_start;
  2009. /**
  2010. * struct auth_info - Data for EVENT_AUTH events
  2011. */
  2012. struct auth_info {
  2013. u8 peer[ETH_ALEN];
  2014. u16 auth_type;
  2015. u16 status_code;
  2016. const u8 *ies;
  2017. size_t ies_len;
  2018. } auth;
  2019. /**
  2020. * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
  2021. */
  2022. struct assoc_reject {
  2023. /**
  2024. * resp_ies - (Re)Association Response IEs
  2025. *
  2026. * Optional association data from the driver. This data is not
  2027. * required WPA, but may be useful for some protocols and as
  2028. * such, should be reported if this is available to the driver
  2029. * interface.
  2030. *
  2031. * This should start with the first IE (fixed fields before IEs
  2032. * are not included).
  2033. */
  2034. u8 *resp_ies;
  2035. /**
  2036. * resp_ies_len - Length of resp_ies in bytes
  2037. */
  2038. size_t resp_ies_len;
  2039. /**
  2040. * status_code - Status Code from (Re)association Response
  2041. */
  2042. u16 status_code;
  2043. } assoc_reject;
  2044. struct timeout_event {
  2045. u8 addr[ETH_ALEN];
  2046. } timeout_event;
  2047. /**
  2048. * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
  2049. */
  2050. struct ft_rrb_rx {
  2051. const u8 *src;
  2052. const u8 *data;
  2053. size_t data_len;
  2054. } ft_rrb_rx;
  2055. /**
  2056. * struct tx_status - Data for EVENT_TX_STATUS events
  2057. */
  2058. struct tx_status {
  2059. u16 type;
  2060. u16 stype;
  2061. const u8 *dst;
  2062. const u8 *data;
  2063. size_t data_len;
  2064. int ack;
  2065. } tx_status;
  2066. /**
  2067. * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
  2068. */
  2069. struct rx_from_unknown {
  2070. const u8 *frame;
  2071. size_t len;
  2072. } rx_from_unknown;
  2073. /**
  2074. * struct rx_mgmt - Data for EVENT_RX_MGMT events
  2075. */
  2076. struct rx_mgmt {
  2077. const u8 *frame;
  2078. size_t frame_len;
  2079. u32 datarate;
  2080. u32 ssi_signal;
  2081. } rx_mgmt;
  2082. /**
  2083. * struct rx_action - Data for EVENT_RX_ACTION events
  2084. */
  2085. struct rx_action {
  2086. /**
  2087. * da - Destination address of the received Action frame
  2088. */
  2089. const u8 *da;
  2090. /**
  2091. * sa - Source address of the received Action frame
  2092. */
  2093. const u8 *sa;
  2094. /**
  2095. * bssid - Address 3 of the received Action frame
  2096. */
  2097. const u8 *bssid;
  2098. /**
  2099. * category - Action frame category
  2100. */
  2101. u8 category;
  2102. /**
  2103. * data - Action frame body after category field
  2104. */
  2105. const u8 *data;
  2106. /**
  2107. * len - Length of data in octets
  2108. */
  2109. size_t len;
  2110. /**
  2111. * freq - Frequency (in MHz) on which the frame was received
  2112. */
  2113. int freq;
  2114. } rx_action;
  2115. /**
  2116. * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
  2117. *
  2118. * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
  2119. */
  2120. struct remain_on_channel {
  2121. /**
  2122. * freq - Channel frequency in MHz
  2123. */
  2124. unsigned int freq;
  2125. /**
  2126. * duration - Duration to remain on the channel in milliseconds
  2127. */
  2128. unsigned int duration;
  2129. } remain_on_channel;
  2130. /**
  2131. * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
  2132. * @aborted: Whether the scan was aborted
  2133. * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
  2134. * @num_freqs: Number of entries in freqs array
  2135. * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
  2136. * SSID)
  2137. * @num_ssids: Number of entries in ssids array
  2138. */
  2139. struct scan_info {
  2140. int aborted;
  2141. const int *freqs;
  2142. size_t num_freqs;
  2143. struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
  2144. size_t num_ssids;
  2145. } scan_info;
  2146. /**
  2147. * struct mlme_rx - Data for EVENT_MLME_RX events
  2148. */
  2149. struct mlme_rx {
  2150. const u8 *buf;
  2151. size_t len;
  2152. int freq;
  2153. int channel;
  2154. int ssi;
  2155. } mlme_rx;
  2156. /**
  2157. * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
  2158. */
  2159. struct rx_probe_req {
  2160. /**
  2161. * sa - Source address of the received Probe Request frame
  2162. */
  2163. const u8 *sa;
  2164. /**
  2165. * ie - IEs from the Probe Request body
  2166. */
  2167. const u8 *ie;
  2168. /**
  2169. * ie_len - Length of ie buffer in octets
  2170. */
  2171. size_t ie_len;
  2172. } rx_probe_req;
  2173. /**
  2174. * struct new_sta - Data for EVENT_NEW_STA events
  2175. */
  2176. struct new_sta {
  2177. const u8 *addr;
  2178. } new_sta;
  2179. /**
  2180. * struct eapol_rx - Data for EVENT_EAPOL_RX events
  2181. */
  2182. struct eapol_rx {
  2183. const u8 *src;
  2184. const u8 *data;
  2185. size_t data_len;
  2186. } eapol_rx;
  2187. };
  2188. /**
  2189. * wpa_supplicant_event - Report a driver event for wpa_supplicant
  2190. * @ctx: Context pointer (wpa_s); this is the ctx variable registered
  2191. * with struct wpa_driver_ops::init()
  2192. * @event: event type (defined above)
  2193. * @data: possible extra data for the event
  2194. *
  2195. * Driver wrapper code should call this function whenever an event is received
  2196. * from the driver.
  2197. */
  2198. void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
  2199. union wpa_event_data *data);
  2200. /*
  2201. * The following inline functions are provided for convenience to simplify
  2202. * event indication for some of the common events.
  2203. */
  2204. static inline void drv_event_assoc(void *ctx, const u8 *addr, const u8 *ie,
  2205. size_t ielen)
  2206. {
  2207. union wpa_event_data event;
  2208. os_memset(&event, 0, sizeof(event));
  2209. event.assoc_info.req_ies = ie;
  2210. event.assoc_info.req_ies_len = ielen;
  2211. event.assoc_info.addr = addr;
  2212. wpa_supplicant_event(ctx, EVENT_ASSOC, &event);
  2213. }
  2214. static inline void drv_event_disassoc(void *ctx, const u8 *addr)
  2215. {
  2216. union wpa_event_data event;
  2217. os_memset(&event, 0, sizeof(event));
  2218. event.disassoc_info.addr = addr;
  2219. wpa_supplicant_event(ctx, EVENT_DISASSOC, &event);
  2220. }
  2221. static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
  2222. size_t data_len)
  2223. {
  2224. union wpa_event_data event;
  2225. os_memset(&event, 0, sizeof(event));
  2226. event.eapol_rx.src = src;
  2227. event.eapol_rx.data = data;
  2228. event.eapol_rx.data_len = data_len;
  2229. wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
  2230. }
  2231. #endif /* DRIVER_H */