driver.h 84 KB

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