driver.h 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513
  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. #define HOSTAPD_CHAN_HT40PLUS 0x00000010
  31. #define HOSTAPD_CHAN_HT40MINUS 0x00000020
  32. #define HOSTAPD_CHAN_HT40 0x00000040
  33. /**
  34. * struct hostapd_channel_data - Channel information
  35. */
  36. struct hostapd_channel_data {
  37. /**
  38. * chan - Channel number (IEEE 802.11)
  39. */
  40. short chan;
  41. /**
  42. * freq - Frequency in MHz
  43. */
  44. short freq;
  45. /**
  46. * flag - Channel flags (HOSTAPD_CHAN_*)
  47. */
  48. int flag;
  49. /**
  50. * max_tx_power - maximum transmit power in dBm
  51. */
  52. u8 max_tx_power;
  53. };
  54. /**
  55. * struct hostapd_hw_modes - Supported hardware mode information
  56. */
  57. struct hostapd_hw_modes {
  58. /**
  59. * mode - Hardware mode
  60. */
  61. enum hostapd_hw_mode mode;
  62. /**
  63. * num_channels - Number of entries in the channels array
  64. */
  65. int num_channels;
  66. /**
  67. * channels - Array of supported channels
  68. */
  69. struct hostapd_channel_data *channels;
  70. /**
  71. * num_rates - Number of entries in the rates array
  72. */
  73. int num_rates;
  74. /**
  75. * rates - Array of supported rates in 100 kbps units
  76. */
  77. int *rates;
  78. /**
  79. * ht_capab - HT (IEEE 802.11n) capabilities
  80. */
  81. u16 ht_capab;
  82. /**
  83. * mcs_set - MCS (IEEE 802.11n) rate parameters
  84. */
  85. u8 mcs_set[16];
  86. /**
  87. * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
  88. */
  89. u8 a_mpdu_params;
  90. };
  91. #define IEEE80211_MODE_INFRA 0
  92. #define IEEE80211_MODE_IBSS 1
  93. #define IEEE80211_MODE_AP 2
  94. #define IEEE80211_CAP_ESS 0x0001
  95. #define IEEE80211_CAP_IBSS 0x0002
  96. #define IEEE80211_CAP_PRIVACY 0x0010
  97. #define WPA_SCAN_QUAL_INVALID BIT(0)
  98. #define WPA_SCAN_NOISE_INVALID BIT(1)
  99. #define WPA_SCAN_LEVEL_INVALID BIT(2)
  100. #define WPA_SCAN_LEVEL_DBM BIT(3)
  101. #define WPA_SCAN_AUTHENTICATED BIT(4)
  102. #define WPA_SCAN_ASSOCIATED BIT(5)
  103. /**
  104. * struct wpa_scan_res - Scan result for an BSS/IBSS
  105. * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
  106. * @bssid: BSSID
  107. * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
  108. * @beacon_int: beacon interval in TUs (host byte order)
  109. * @caps: capability information field in host byte order
  110. * @qual: signal quality
  111. * @noise: noise level
  112. * @level: signal level
  113. * @tsf: Timestamp
  114. * @age: Age of the information in milliseconds (i.e., how many milliseconds
  115. * ago the last Beacon or Probe Response frame was received)
  116. * @ie_len: length of the following IE field in octets
  117. * @beacon_ie_len: length of the following Beacon IE field in octets
  118. *
  119. * This structure is used as a generic format for scan results from the
  120. * driver. Each driver interface implementation is responsible for converting
  121. * the driver or OS specific scan results into this format.
  122. *
  123. * If the driver does not support reporting all IEs, the IE data structure is
  124. * constructed of the IEs that are available. This field will also need to
  125. * include SSID in IE format. All drivers are encouraged to be extended to
  126. * report all IEs to make it easier to support future additions.
  127. */
  128. struct wpa_scan_res {
  129. unsigned int flags;
  130. u8 bssid[ETH_ALEN];
  131. int freq;
  132. u16 beacon_int;
  133. u16 caps;
  134. int qual;
  135. int noise;
  136. int level;
  137. u64 tsf;
  138. unsigned int age;
  139. size_t ie_len;
  140. size_t beacon_ie_len;
  141. /*
  142. * Followed by ie_len octets of IEs from Probe Response frame (or if
  143. * the driver does not indicate source of IEs, these may also be from
  144. * Beacon frame). After the first set of IEs, another set of IEs may
  145. * follow (with beacon_ie_len octets of data) if the driver provides
  146. * both IE sets.
  147. */
  148. };
  149. /**
  150. * struct wpa_scan_results - Scan results
  151. * @res: Array of pointers to allocated variable length scan result entries
  152. * @num: Number of entries in the scan result array
  153. */
  154. struct wpa_scan_results {
  155. struct wpa_scan_res **res;
  156. size_t num;
  157. };
  158. /**
  159. * struct wpa_interface_info - Network interface information
  160. * @next: Pointer to the next interface or NULL if this is the last one
  161. * @ifname: Interface name that can be used with init() or init2()
  162. * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
  163. * not available
  164. * @drv_name: struct wpa_driver_ops::name (note: unlike other strings, this one
  165. * is not an allocated copy, i.e., get_interfaces() caller will not free
  166. * this)
  167. */
  168. struct wpa_interface_info {
  169. struct wpa_interface_info *next;
  170. char *ifname;
  171. char *desc;
  172. const char *drv_name;
  173. };
  174. #define WPAS_MAX_SCAN_SSIDS 16
  175. /**
  176. * struct wpa_driver_scan_params - Scan parameters
  177. * Data for struct wpa_driver_ops::scan2().
  178. */
  179. struct wpa_driver_scan_params {
  180. /**
  181. * ssids - SSIDs to scan for
  182. */
  183. struct wpa_driver_scan_ssid {
  184. /**
  185. * ssid - specific SSID to scan for (ProbeReq)
  186. * %NULL or zero-length SSID is used to indicate active scan
  187. * with wildcard SSID.
  188. */
  189. const u8 *ssid;
  190. /**
  191. * ssid_len: Length of the SSID in octets
  192. */
  193. size_t ssid_len;
  194. } ssids[WPAS_MAX_SCAN_SSIDS];
  195. /**
  196. * num_ssids - Number of entries in ssids array
  197. * Zero indicates a request for a passive scan.
  198. */
  199. size_t num_ssids;
  200. /**
  201. * extra_ies - Extra IE(s) to add into Probe Request or %NULL
  202. */
  203. const u8 *extra_ies;
  204. /**
  205. * extra_ies_len - Length of extra_ies in octets
  206. */
  207. size_t extra_ies_len;
  208. /**
  209. * freqs - Array of frequencies to scan or %NULL for all frequencies
  210. *
  211. * The frequency is set in MHz. The array is zero-terminated.
  212. */
  213. int *freqs;
  214. /**
  215. * filter_ssids - Filter for reporting SSIDs
  216. *
  217. * This optional parameter can be used to request the driver wrapper to
  218. * filter scan results to include only the specified SSIDs. %NULL
  219. * indicates that no filtering is to be done. This can be used to
  220. * reduce memory needs for scan results in environments that have large
  221. * number of APs with different SSIDs.
  222. *
  223. * The driver wrapper is allowed to take this allocated buffer into its
  224. * own use by setting the pointer to %NULL. In that case, the driver
  225. * wrapper is responsible for freeing the buffer with os_free() once it
  226. * is not needed anymore.
  227. */
  228. struct wpa_driver_scan_filter {
  229. u8 ssid[32];
  230. size_t ssid_len;
  231. } *filter_ssids;
  232. /**
  233. * num_filter_ssids - Number of entries in filter_ssids array
  234. */
  235. size_t num_filter_ssids;
  236. /**
  237. * p2p_probe - Used to disable CCK (802.11b) rates for P2P probes
  238. *
  239. * When set, the driver is expected to remove rates 1, 2, 5.5, and 11
  240. * Mbps from the support rates element(s) in the Probe Request frames
  241. * and not to transmit the frames at any of those rates.
  242. */
  243. u8 p2p_probe;
  244. };
  245. /**
  246. * struct wpa_driver_auth_params - Authentication parameters
  247. * Data for struct wpa_driver_ops::authenticate().
  248. */
  249. struct wpa_driver_auth_params {
  250. int freq;
  251. const u8 *bssid;
  252. const u8 *ssid;
  253. size_t ssid_len;
  254. int auth_alg;
  255. const u8 *ie;
  256. size_t ie_len;
  257. const u8 *wep_key[4];
  258. size_t wep_key_len[4];
  259. int wep_tx_keyidx;
  260. int local_state_change;
  261. /**
  262. * p2p - Whether this connection is a P2P group
  263. */
  264. int p2p;
  265. };
  266. enum wps_mode {
  267. WPS_MODE_NONE /* no WPS provisioning being used */,
  268. WPS_MODE_OPEN /* WPS provisioning with AP that is in open mode */,
  269. WPS_MODE_PRIVACY /* WPS provisioning with AP that is using protection
  270. */
  271. };
  272. /**
  273. * struct wpa_driver_associate_params - Association parameters
  274. * Data for struct wpa_driver_ops::associate().
  275. */
  276. struct wpa_driver_associate_params {
  277. /**
  278. * bssid - BSSID of the selected AP
  279. * This can be %NULL, if ap_scan=2 mode is used and the driver is
  280. * responsible for selecting with which BSS to associate. */
  281. const u8 *bssid;
  282. /**
  283. * ssid - The selected SSID
  284. */
  285. const u8 *ssid;
  286. /**
  287. * ssid_len - Length of the SSID (1..32)
  288. */
  289. size_t ssid_len;
  290. /**
  291. * freq - Frequency of the channel the selected AP is using
  292. * Frequency that the selected AP is using (in MHz as
  293. * reported in the scan results)
  294. */
  295. int freq;
  296. /**
  297. * wpa_ie - WPA information element for (Re)Association Request
  298. * WPA information element to be included in (Re)Association
  299. * Request (including information element id and length). Use
  300. * of this WPA IE is optional. If the driver generates the WPA
  301. * IE, it can use pairwise_suite, group_suite, and
  302. * key_mgmt_suite to select proper algorithms. In this case,
  303. * the driver has to notify wpa_supplicant about the used WPA
  304. * IE by generating an event that the interface code will
  305. * convert into EVENT_ASSOCINFO data (see below).
  306. *
  307. * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
  308. * instead. The driver can determine which version is used by
  309. * looking at the first byte of the IE (0xdd for WPA, 0x30 for
  310. * WPA2/RSN).
  311. *
  312. * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
  313. */
  314. const u8 *wpa_ie;
  315. /**
  316. * wpa_ie_len - length of the wpa_ie
  317. */
  318. size_t wpa_ie_len;
  319. /**
  320. * wpa_proto - Bitfield of WPA_PROTO_* values to indicate WPA/WPA2
  321. */
  322. unsigned int wpa_proto;
  323. /**
  324. * pairwise_suite - Selected pairwise cipher suite
  325. *
  326. * This is usually ignored if @wpa_ie is used.
  327. */
  328. enum wpa_cipher pairwise_suite;
  329. /**
  330. * group_suite - Selected group cipher suite
  331. *
  332. * This is usually ignored if @wpa_ie is used.
  333. */
  334. enum wpa_cipher group_suite;
  335. /**
  336. * key_mgmt_suite - Selected key management suite
  337. *
  338. * This is usually ignored if @wpa_ie is used.
  339. */
  340. enum wpa_key_mgmt key_mgmt_suite;
  341. /**
  342. * auth_alg - Allowed authentication algorithms
  343. * Bit field of WPA_AUTH_ALG_*
  344. */
  345. int auth_alg;
  346. /**
  347. * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
  348. */
  349. int mode;
  350. /**
  351. * wep_key - WEP keys for static WEP configuration
  352. */
  353. const u8 *wep_key[4];
  354. /**
  355. * wep_key_len - WEP key length for static WEP configuration
  356. */
  357. size_t wep_key_len[4];
  358. /**
  359. * wep_tx_keyidx - WEP TX key index for static WEP configuration
  360. */
  361. int wep_tx_keyidx;
  362. /**
  363. * mgmt_frame_protection - IEEE 802.11w management frame protection
  364. */
  365. enum mfp_options mgmt_frame_protection;
  366. /**
  367. * ft_ies - IEEE 802.11r / FT information elements
  368. * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
  369. * for fast transition, this parameter is set to include the IEs that
  370. * are to be sent in the next FT Authentication Request message.
  371. * update_ft_ies() handler is called to update the IEs for further
  372. * FT messages in the sequence.
  373. *
  374. * The driver should use these IEs only if the target AP is advertising
  375. * the same mobility domain as the one included in the MDIE here.
  376. *
  377. * In ap_scan=2 mode, the driver can use these IEs when moving to a new
  378. * AP after the initial association. These IEs can only be used if the
  379. * target AP is advertising support for FT and is using the same MDIE
  380. * and SSID as the current AP.
  381. *
  382. * The driver is responsible for reporting the FT IEs received from the
  383. * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
  384. * type. update_ft_ies() handler will then be called with the FT IEs to
  385. * include in the next frame in the authentication sequence.
  386. */
  387. const u8 *ft_ies;
  388. /**
  389. * ft_ies_len - Length of ft_ies in bytes
  390. */
  391. size_t ft_ies_len;
  392. /**
  393. * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
  394. *
  395. * This value is provided to allow the driver interface easier access
  396. * to the current mobility domain. This value is set to %NULL if no
  397. * mobility domain is currently active.
  398. */
  399. const u8 *ft_md;
  400. /**
  401. * passphrase - RSN passphrase for PSK
  402. *
  403. * This value is made available only for WPA/WPA2-Personal (PSK) and
  404. * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
  405. * the 8..63 character ASCII passphrase, if available. Please note that
  406. * this can be %NULL if passphrase was not used to generate the PSK. In
  407. * that case, the psk field must be used to fetch the PSK.
  408. */
  409. const char *passphrase;
  410. /**
  411. * psk - RSN PSK (alternative for passphrase for PSK)
  412. *
  413. * This value is made available only for WPA/WPA2-Personal (PSK) and
  414. * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
  415. * the 32-octet (256-bit) PSK, if available. The driver wrapper should
  416. * be prepared to handle %NULL value as an error.
  417. */
  418. const u8 *psk;
  419. /**
  420. * drop_unencrypted - Enable/disable unencrypted frame filtering
  421. *
  422. * Configure the driver to drop all non-EAPOL frames (both receive and
  423. * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
  424. * still be allowed for key negotiation.
  425. */
  426. int drop_unencrypted;
  427. /**
  428. * prev_bssid - Previously used BSSID in this ESS
  429. *
  430. * When not %NULL, this is a request to use reassociation instead of
  431. * association.
  432. */
  433. const u8 *prev_bssid;
  434. /**
  435. * wps - WPS mode
  436. *
  437. * If the driver needs to do special configuration for WPS association,
  438. * this variable provides more information on what type of association
  439. * is being requested. Most drivers should not need ot use this.
  440. */
  441. enum wps_mode wps;
  442. /**
  443. * p2p - Whether this connection is a P2P group
  444. */
  445. int p2p;
  446. /**
  447. * uapsd - UAPSD parameters for the network
  448. * -1 = do not change defaults
  449. * AP mode: 1 = enabled, 0 = disabled
  450. * STA mode: bits 0..3 UAPSD enabled for VO,VI,BK,BE
  451. */
  452. int uapsd;
  453. };
  454. enum hide_ssid {
  455. NO_SSID_HIDING,
  456. HIDDEN_SSID_ZERO_LEN,
  457. HIDDEN_SSID_ZERO_CONTENTS
  458. };
  459. struct wpa_driver_ap_params {
  460. /**
  461. * head - Beacon head from IEEE 802.11 header to IEs before TIM IE
  462. */
  463. const u8 *head;
  464. /**
  465. * head_len - Length of the head buffer in octets
  466. */
  467. size_t head_len;
  468. /**
  469. * tail - Beacon tail following TIM IE
  470. */
  471. const u8 *tail;
  472. /**
  473. * tail_len - Length of the tail buffer in octets
  474. */
  475. size_t tail_len;
  476. /**
  477. * dtim_period - DTIM period
  478. */
  479. int dtim_period;
  480. /**
  481. * beacon_int - Beacon interval
  482. */
  483. int beacon_int;
  484. /**
  485. * ssid - The SSID to use in Beacon/Probe Response frames
  486. */
  487. const u8 *ssid;
  488. /**
  489. * ssid_len - Length of the SSID (1..32)
  490. */
  491. size_t ssid_len;
  492. /**
  493. * hide_ssid - Whether to hide the SSID
  494. */
  495. enum hide_ssid hide_ssid;
  496. /**
  497. * pairwise_ciphers - WPA_CIPHER_* bitfield
  498. */
  499. unsigned int pairwise_ciphers;
  500. /**
  501. * group_cipher - WPA_CIPHER_*
  502. */
  503. unsigned int group_cipher;
  504. /**
  505. * key_mgmt_suites - WPA_KEY_MGMT_* bitfield
  506. */
  507. unsigned int key_mgmt_suites;
  508. /**
  509. * auth_algs - WPA_AUTH_ALG_* bitfield
  510. */
  511. unsigned int auth_algs;
  512. /**
  513. * wpa_version - WPA_PROTO_* bitfield
  514. */
  515. unsigned int wpa_version;
  516. /**
  517. * privacy - Whether privacy is used in the BSS
  518. */
  519. int privacy;
  520. /**
  521. * beacon_ies - WPS/P2P IE(s) for Beacon frames
  522. *
  523. * This is used to add IEs like WPS IE and P2P IE by drivers that do
  524. * not use the full Beacon template.
  525. */
  526. const struct wpabuf *beacon_ies;
  527. /**
  528. * proberesp_ies - P2P/WPS IE(s) for Probe Response frames
  529. *
  530. * This is used to add IEs like WPS IE and P2P IE by drivers that
  531. * reply to Probe Request frames internally.
  532. */
  533. const struct wpabuf *proberesp_ies;
  534. /**
  535. * assocresp_ies - WPS IE(s) for (Re)Association Response frames
  536. */
  537. const struct wpabuf *assocresp_ies;
  538. };
  539. /**
  540. * struct wpa_driver_capa - Driver capability information
  541. */
  542. struct wpa_driver_capa {
  543. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA 0x00000001
  544. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2 0x00000002
  545. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK 0x00000004
  546. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK 0x00000008
  547. #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE 0x00000010
  548. #define WPA_DRIVER_CAPA_KEY_MGMT_FT 0x00000020
  549. #define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK 0x00000040
  550. unsigned int key_mgmt;
  551. #define WPA_DRIVER_CAPA_ENC_WEP40 0x00000001
  552. #define WPA_DRIVER_CAPA_ENC_WEP104 0x00000002
  553. #define WPA_DRIVER_CAPA_ENC_TKIP 0x00000004
  554. #define WPA_DRIVER_CAPA_ENC_CCMP 0x00000008
  555. unsigned int enc;
  556. #define WPA_DRIVER_AUTH_OPEN 0x00000001
  557. #define WPA_DRIVER_AUTH_SHARED 0x00000002
  558. #define WPA_DRIVER_AUTH_LEAP 0x00000004
  559. unsigned int auth;
  560. /* Driver generated WPA/RSN IE */
  561. #define WPA_DRIVER_FLAGS_DRIVER_IE 0x00000001
  562. /* Driver needs static WEP key setup after association command */
  563. #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
  564. #define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
  565. /* Driver takes care of RSN 4-way handshake internally; PMK is configured with
  566. * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
  567. #define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
  568. #define WPA_DRIVER_FLAGS_WIRED 0x00000010
  569. /* Driver provides separate commands for authentication and association (SME in
  570. * wpa_supplicant). */
  571. #define WPA_DRIVER_FLAGS_SME 0x00000020
  572. /* Driver supports AP mode */
  573. #define WPA_DRIVER_FLAGS_AP 0x00000040
  574. /* Driver needs static WEP key setup after association has been completed */
  575. #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE 0x00000080
  576. /* Driver takes care of P2P management operations */
  577. #define WPA_DRIVER_FLAGS_P2P_MGMT 0x00000100
  578. /* Driver supports concurrent P2P operations */
  579. #define WPA_DRIVER_FLAGS_P2P_CONCURRENT 0x00000200
  580. /*
  581. * Driver uses the initial interface as a dedicated management interface, i.e.,
  582. * it cannot be used for P2P group operations or non-P2P purposes.
  583. */
  584. #define WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE 0x00000400
  585. /* This interface is P2P capable (P2P Device, GO, or P2P Client */
  586. #define WPA_DRIVER_FLAGS_P2P_CAPABLE 0x00000800
  587. /* Driver supports concurrent operations on multiple channels */
  588. #define WPA_DRIVER_FLAGS_MULTI_CHANNEL_CONCURRENT 0x00001000
  589. /*
  590. * Driver uses the initial interface for P2P management interface and non-P2P
  591. * purposes (e.g., connect to infra AP), but this interface cannot be used for
  592. * P2P group operations.
  593. */
  594. #define WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P 0x00002000
  595. /*
  596. * Driver is known to use sane error codes, i.e., when it indicates that
  597. * something (e.g., association) fails, there was indeed a failure and the
  598. * operation does not end up getting completed successfully later.
  599. */
  600. #define WPA_DRIVER_FLAGS_SANE_ERROR_CODES 0x00004000
  601. /* Driver supports off-channel TX */
  602. #define WPA_DRIVER_FLAGS_OFFCHANNEL_TX 0x00008000
  603. /* Driver indicates TX status events for EAPOL Data frames */
  604. #define WPA_DRIVER_FLAGS_EAPOL_TX_STATUS 0x00010000
  605. /* Driver indicates TX status events for Deauth/Disassoc frames */
  606. #define WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS 0x00020000
  607. /* Driver supports roaming (BSS selection) in firmware */
  608. #define WPA_DRIVER_FLAGS_BSS_SELECTION 0x00040000
  609. unsigned int flags;
  610. int max_scan_ssids;
  611. int max_sched_scan_ssids;
  612. int sched_scan_supported;
  613. int max_match_sets;
  614. /**
  615. * max_remain_on_chan - Maximum remain-on-channel duration in msec
  616. */
  617. unsigned int max_remain_on_chan;
  618. /**
  619. * max_stations - Maximum number of associated stations the driver
  620. * supports in AP mode
  621. */
  622. unsigned int max_stations;
  623. };
  624. struct hostapd_data;
  625. struct hostap_sta_driver_data {
  626. unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
  627. unsigned long current_tx_rate;
  628. unsigned long inactive_msec;
  629. unsigned long flags;
  630. unsigned long num_ps_buf_frames;
  631. unsigned long tx_retry_failed;
  632. unsigned long tx_retry_count;
  633. int last_rssi;
  634. int last_ack_rssi;
  635. };
  636. struct hostapd_sta_add_params {
  637. const u8 *addr;
  638. u16 aid;
  639. u16 capability;
  640. const u8 *supp_rates;
  641. size_t supp_rates_len;
  642. u16 listen_interval;
  643. const struct ieee80211_ht_capabilities *ht_capabilities;
  644. u32 flags; /* bitmask of WPA_STA_* flags */
  645. };
  646. struct hostapd_freq_params {
  647. int mode;
  648. int freq;
  649. int channel;
  650. int ht_enabled;
  651. int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
  652. * secondary channel below primary, 1 = HT40
  653. * enabled, secondary channel above primary */
  654. };
  655. enum wpa_driver_if_type {
  656. /**
  657. * WPA_IF_STATION - Station mode interface
  658. */
  659. WPA_IF_STATION,
  660. /**
  661. * WPA_IF_AP_VLAN - AP mode VLAN interface
  662. *
  663. * This interface shares its address and Beacon frame with the main
  664. * BSS.
  665. */
  666. WPA_IF_AP_VLAN,
  667. /**
  668. * WPA_IF_AP_BSS - AP mode BSS interface
  669. *
  670. * This interface has its own address and Beacon frame.
  671. */
  672. WPA_IF_AP_BSS,
  673. /**
  674. * WPA_IF_P2P_GO - P2P Group Owner
  675. */
  676. WPA_IF_P2P_GO,
  677. /**
  678. * WPA_IF_P2P_CLIENT - P2P Client
  679. */
  680. WPA_IF_P2P_CLIENT,
  681. /**
  682. * WPA_IF_P2P_GROUP - P2P Group interface (will become either
  683. * WPA_IF_P2P_GO or WPA_IF_P2P_CLIENT, but the role is not yet known)
  684. */
  685. WPA_IF_P2P_GROUP
  686. };
  687. struct wpa_init_params {
  688. const u8 *bssid;
  689. const char *ifname;
  690. const u8 *ssid;
  691. size_t ssid_len;
  692. const char *test_socket;
  693. int use_pae_group_addr;
  694. char **bridge;
  695. size_t num_bridge;
  696. u8 *own_addr; /* buffer for writing own MAC address */
  697. };
  698. struct wpa_bss_params {
  699. /** Interface name (for multi-SSID/VLAN support) */
  700. const char *ifname;
  701. /** Whether IEEE 802.1X or WPA/WPA2 is enabled */
  702. int enabled;
  703. int wpa;
  704. int ieee802_1x;
  705. int wpa_group;
  706. int wpa_pairwise;
  707. int wpa_key_mgmt;
  708. int rsn_preauth;
  709. enum mfp_options ieee80211w;
  710. };
  711. #define WPA_STA_AUTHORIZED BIT(0)
  712. #define WPA_STA_WMM BIT(1)
  713. #define WPA_STA_SHORT_PREAMBLE BIT(2)
  714. #define WPA_STA_MFP BIT(3)
  715. /**
  716. * struct p2p_params - P2P parameters for driver-based P2P management
  717. */
  718. struct p2p_params {
  719. const char *dev_name;
  720. u8 pri_dev_type[8];
  721. #define DRV_MAX_SEC_DEV_TYPES 5
  722. u8 sec_dev_type[DRV_MAX_SEC_DEV_TYPES][8];
  723. size_t num_sec_dev_types;
  724. };
  725. enum tdls_oper {
  726. TDLS_DISCOVERY_REQ,
  727. TDLS_SETUP,
  728. TDLS_TEARDOWN,
  729. TDLS_ENABLE_LINK,
  730. TDLS_DISABLE_LINK,
  731. TDLS_ENABLE,
  732. TDLS_DISABLE
  733. };
  734. /**
  735. * struct wpa_signal_info - Information about channel signal quality
  736. */
  737. struct wpa_signal_info {
  738. u32 frequency;
  739. int above_threshold;
  740. int current_signal;
  741. int current_noise;
  742. int current_txrate;
  743. };
  744. /**
  745. * struct wpa_driver_ops - Driver interface API definition
  746. *
  747. * This structure defines the API that each driver interface needs to implement
  748. * for core wpa_supplicant code. All driver specific functionality is captured
  749. * in this wrapper.
  750. */
  751. struct wpa_driver_ops {
  752. /** Name of the driver interface */
  753. const char *name;
  754. /** One line description of the driver interface */
  755. const char *desc;
  756. /**
  757. * get_bssid - Get the current BSSID
  758. * @priv: private driver interface data
  759. * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
  760. *
  761. * Returns: 0 on success, -1 on failure
  762. *
  763. * Query kernel driver for the current BSSID and copy it to bssid.
  764. * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
  765. * associated.
  766. */
  767. int (*get_bssid)(void *priv, u8 *bssid);
  768. /**
  769. * get_ssid - Get the current SSID
  770. * @priv: private driver interface data
  771. * @ssid: buffer for SSID (at least 32 bytes)
  772. *
  773. * Returns: Length of the SSID on success, -1 on failure
  774. *
  775. * Query kernel driver for the current SSID and copy it to ssid.
  776. * Returning zero is recommended if the STA is not associated.
  777. *
  778. * Note: SSID is an array of octets, i.e., it is not nul terminated and
  779. * can, at least in theory, contain control characters (including nul)
  780. * and as such, should be processed as binary data, not a printable
  781. * string.
  782. */
  783. int (*get_ssid)(void *priv, u8 *ssid);
  784. /**
  785. * set_key - Configure encryption key
  786. * @ifname: Interface name (for multi-SSID/VLAN support)
  787. * @priv: private driver interface data
  788. * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
  789. * %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
  790. * %WPA_ALG_NONE clears the key.
  791. * @addr: Address of the peer STA (BSSID of the current AP when setting
  792. * pairwise key in station mode), ff:ff:ff:ff:ff:ff for
  793. * broadcast keys, %NULL for default keys that are used both for
  794. * broadcast and unicast; when clearing keys, %NULL is used to
  795. * indicate that both the broadcast-only and default key of the
  796. * specified key index is to be cleared
  797. * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
  798. * IGTK
  799. * @set_tx: configure this key as the default Tx key (only used when
  800. * driver does not support separate unicast/individual key
  801. * @seq: sequence number/packet number, seq_len octets, the next
  802. * packet number to be used for in replay protection; configured
  803. * for Rx keys (in most cases, this is only used with broadcast
  804. * keys and set to zero for unicast keys); %NULL if not set
  805. * @seq_len: length of the seq, depends on the algorithm:
  806. * TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
  807. * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
  808. * 8-byte Rx Mic Key
  809. * @key_len: length of the key buffer in octets (WEP: 5 or 13,
  810. * TKIP: 32, CCMP: 16, IGTK: 16)
  811. *
  812. * Returns: 0 on success, -1 on failure
  813. *
  814. * Configure the given key for the kernel driver. If the driver
  815. * supports separate individual keys (4 default keys + 1 individual),
  816. * addr can be used to determine whether the key is default or
  817. * individual. If only 4 keys are supported, the default key with key
  818. * index 0 is used as the individual key. STA must be configured to use
  819. * it as the default Tx key (set_tx is set) and accept Rx for all the
  820. * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
  821. * broadcast keys, so key index 0 is available for this kind of
  822. * configuration.
  823. *
  824. * Please note that TKIP keys include separate TX and RX MIC keys and
  825. * some drivers may expect them in different order than wpa_supplicant
  826. * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
  827. * will trigger Michael MIC errors. This can be fixed by changing the
  828. * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
  829. * in driver_*.c set_key() implementation, see driver_ndis.c for an
  830. * example on how this can be done.
  831. */
  832. int (*set_key)(const char *ifname, void *priv, enum wpa_alg alg,
  833. const u8 *addr, int key_idx, int set_tx,
  834. const u8 *seq, size_t seq_len,
  835. const u8 *key, size_t key_len);
  836. /**
  837. * init - Initialize driver interface
  838. * @ctx: context to be used when calling wpa_supplicant functions,
  839. * e.g., wpa_supplicant_event()
  840. * @ifname: interface name, e.g., wlan0
  841. *
  842. * Returns: Pointer to private data, %NULL on failure
  843. *
  844. * Initialize driver interface, including event processing for kernel
  845. * driver events (e.g., associated, scan results, Michael MIC failure).
  846. * This function can allocate a private configuration data area for
  847. * @ctx, file descriptor, interface name, etc. information that may be
  848. * needed in future driver operations. If this is not used, non-NULL
  849. * value will need to be returned because %NULL is used to indicate
  850. * failure. The returned value will be used as 'void *priv' data for
  851. * all other driver_ops functions.
  852. *
  853. * The main event loop (eloop.c) of wpa_supplicant can be used to
  854. * register callback for read sockets (eloop_register_read_sock()).
  855. *
  856. * See below for more information about events and
  857. * wpa_supplicant_event() function.
  858. */
  859. void * (*init)(void *ctx, const char *ifname);
  860. /**
  861. * deinit - Deinitialize driver interface
  862. * @priv: private driver interface data from init()
  863. *
  864. * Shut down driver interface and processing of driver events. Free
  865. * private data buffer if one was allocated in init() handler.
  866. */
  867. void (*deinit)(void *priv);
  868. /**
  869. * set_param - Set driver configuration parameters
  870. * @priv: private driver interface data from init()
  871. * @param: driver specific configuration parameters
  872. *
  873. * Returns: 0 on success, -1 on failure
  874. *
  875. * Optional handler for notifying driver interface about configuration
  876. * parameters (driver_param).
  877. */
  878. int (*set_param)(void *priv, const char *param);
  879. /**
  880. * set_countermeasures - Enable/disable TKIP countermeasures
  881. * @priv: private driver interface data
  882. * @enabled: 1 = countermeasures enabled, 0 = disabled
  883. *
  884. * Returns: 0 on success, -1 on failure
  885. *
  886. * Configure TKIP countermeasures. When these are enabled, the driver
  887. * should drop all received and queued frames that are using TKIP.
  888. */
  889. int (*set_countermeasures)(void *priv, int enabled);
  890. /**
  891. * deauthenticate - Request driver to deauthenticate
  892. * @priv: private driver interface data
  893. * @addr: peer address (BSSID of the AP)
  894. * @reason_code: 16-bit reason code to be sent in the deauthentication
  895. * frame
  896. *
  897. * Returns: 0 on success, -1 on failure
  898. */
  899. int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
  900. /**
  901. * disassociate - Request driver to disassociate
  902. * @priv: private driver interface data
  903. * @addr: peer address (BSSID of the AP)
  904. * @reason_code: 16-bit reason code to be sent in the disassociation
  905. * frame
  906. *
  907. * Returns: 0 on success, -1 on failure
  908. */
  909. int (*disassociate)(void *priv, const u8 *addr, int reason_code);
  910. /**
  911. * associate - Request driver to associate
  912. * @priv: private driver interface data
  913. * @params: association parameters
  914. *
  915. * Returns: 0 on success, -1 on failure
  916. */
  917. int (*associate)(void *priv,
  918. struct wpa_driver_associate_params *params);
  919. /**
  920. * add_pmkid - Add PMKSA cache entry to the driver
  921. * @priv: private driver interface data
  922. * @bssid: BSSID for the PMKSA cache entry
  923. * @pmkid: PMKID for the PMKSA cache entry
  924. *
  925. * Returns: 0 on success, -1 on failure
  926. *
  927. * This function is called when a new PMK is received, as a result of
  928. * either normal authentication or RSN pre-authentication.
  929. *
  930. * If the driver generates RSN IE, i.e., it does not use wpa_ie in
  931. * associate(), add_pmkid() can be used to add new PMKSA cache entries
  932. * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
  933. * driver_ops function does not need to be implemented. Likewise, if
  934. * the driver does not support WPA, this function is not needed.
  935. */
  936. int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
  937. /**
  938. * remove_pmkid - Remove PMKSA cache entry to the driver
  939. * @priv: private driver interface data
  940. * @bssid: BSSID for the PMKSA cache entry
  941. * @pmkid: PMKID for the PMKSA cache entry
  942. *
  943. * Returns: 0 on success, -1 on failure
  944. *
  945. * This function is called when the supplicant drops a PMKSA cache
  946. * entry for any reason.
  947. *
  948. * If the driver generates RSN IE, i.e., it does not use wpa_ie in
  949. * associate(), remove_pmkid() can be used to synchronize PMKSA caches
  950. * between the driver and wpa_supplicant. If the driver uses wpa_ie
  951. * from wpa_supplicant, this driver_ops function does not need to be
  952. * implemented. Likewise, if the driver does not support WPA, this
  953. * function is not needed.
  954. */
  955. int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
  956. /**
  957. * flush_pmkid - Flush PMKSA cache
  958. * @priv: private driver interface data
  959. *
  960. * Returns: 0 on success, -1 on failure
  961. *
  962. * This function is called when the supplicant drops all PMKSA cache
  963. * entries for any reason.
  964. *
  965. * If the driver generates RSN IE, i.e., it does not use wpa_ie in
  966. * associate(), remove_pmkid() can be used to synchronize PMKSA caches
  967. * between the driver and wpa_supplicant. If the driver uses wpa_ie
  968. * from wpa_supplicant, this driver_ops function does not need to be
  969. * implemented. Likewise, if the driver does not support WPA, this
  970. * function is not needed.
  971. */
  972. int (*flush_pmkid)(void *priv);
  973. /**
  974. * get_capa - Get driver capabilities
  975. * @priv: private driver interface data
  976. *
  977. * Returns: 0 on success, -1 on failure
  978. *
  979. * Get driver/firmware/hardware capabilities.
  980. */
  981. int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
  982. /**
  983. * poll - Poll driver for association information
  984. * @priv: private driver interface data
  985. *
  986. * This is an option callback that can be used when the driver does not
  987. * provide event mechanism for association events. This is called when
  988. * receiving WPA EAPOL-Key messages that require association
  989. * information. The driver interface is supposed to generate associnfo
  990. * event before returning from this callback function. In addition, the
  991. * driver interface should generate an association event after having
  992. * sent out associnfo.
  993. */
  994. void (*poll)(void *priv);
  995. /**
  996. * get_ifname - Get interface name
  997. * @priv: private driver interface data
  998. *
  999. * Returns: Pointer to the interface name. This can differ from the
  1000. * interface name used in init() call. Init() is called first.
  1001. *
  1002. * This optional function can be used to allow the driver interface to
  1003. * replace the interface name with something else, e.g., based on an
  1004. * interface mapping from a more descriptive name.
  1005. */
  1006. const char * (*get_ifname)(void *priv);
  1007. /**
  1008. * get_mac_addr - Get own MAC address
  1009. * @priv: private driver interface data
  1010. *
  1011. * Returns: Pointer to own MAC address or %NULL on failure
  1012. *
  1013. * This optional function can be used to get the own MAC address of the
  1014. * device from the driver interface code. This is only needed if the
  1015. * l2_packet implementation for the OS does not provide easy access to
  1016. * a MAC address. */
  1017. const u8 * (*get_mac_addr)(void *priv);
  1018. /**
  1019. * send_eapol - Optional function for sending EAPOL packets
  1020. * @priv: private driver interface data
  1021. * @dest: Destination MAC address
  1022. * @proto: Ethertype
  1023. * @data: EAPOL packet starting with IEEE 802.1X header
  1024. * @data_len: Size of the EAPOL packet
  1025. *
  1026. * Returns: 0 on success, -1 on failure
  1027. *
  1028. * This optional function can be used to override l2_packet operations
  1029. * with driver specific functionality. If this function pointer is set,
  1030. * l2_packet module is not used at all and the driver interface code is
  1031. * responsible for receiving and sending all EAPOL packets. The
  1032. * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
  1033. * event. The driver interface is required to implement get_mac_addr()
  1034. * handler if send_eapol() is used.
  1035. */
  1036. int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
  1037. const u8 *data, size_t data_len);
  1038. /**
  1039. * set_operstate - Sets device operating state to DORMANT or UP
  1040. * @priv: private driver interface data
  1041. * @state: 0 = dormant, 1 = up
  1042. * Returns: 0 on success, -1 on failure
  1043. *
  1044. * This is an optional function that can be used on operating systems
  1045. * that support a concept of controlling network device state from user
  1046. * space applications. This function, if set, gets called with
  1047. * state = 1 when authentication has been completed and with state = 0
  1048. * when connection is lost.
  1049. */
  1050. int (*set_operstate)(void *priv, int state);
  1051. /**
  1052. * mlme_setprotection - MLME-SETPROTECTION.request primitive
  1053. * @priv: Private driver interface data
  1054. * @addr: Address of the station for which to set protection (may be
  1055. * %NULL for group keys)
  1056. * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
  1057. * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
  1058. * Returns: 0 on success, -1 on failure
  1059. *
  1060. * This is an optional function that can be used to set the driver to
  1061. * require protection for Tx and/or Rx frames. This uses the layer
  1062. * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
  1063. * (MLME-SETPROTECTION.request). Many drivers do not use explicit
  1064. * set protection operation; instead, they set protection implicitly
  1065. * based on configured keys.
  1066. */
  1067. int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
  1068. int key_type);
  1069. /**
  1070. * get_hw_feature_data - Get hardware support data (channels and rates)
  1071. * @priv: Private driver interface data
  1072. * @num_modes: Variable for returning the number of returned modes
  1073. * flags: Variable for returning hardware feature flags
  1074. * Returns: Pointer to allocated hardware data on success or %NULL on
  1075. * failure. Caller is responsible for freeing this.
  1076. *
  1077. * This function is only needed for drivers that export MLME
  1078. * (management frame processing) to %wpa_supplicant or hostapd.
  1079. */
  1080. struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
  1081. u16 *num_modes,
  1082. u16 *flags);
  1083. /**
  1084. * set_channel - Set channel
  1085. * @priv: Private driver interface data
  1086. * @phymode: HOSTAPD_MODE_IEEE80211B, ..
  1087. * @chan: IEEE 802.11 channel number
  1088. * @freq: Frequency of the channel in MHz
  1089. * Returns: 0 on success, -1 on failure
  1090. *
  1091. * This function is only needed for drivers that export MLME
  1092. * (management frame processing) to wpa_supplicant.
  1093. */
  1094. int (*set_channel)(void *priv, enum hostapd_hw_mode phymode, int chan,
  1095. int freq);
  1096. /**
  1097. * set_ssid - Set SSID
  1098. * @priv: Private driver interface data
  1099. * @ssid: SSID
  1100. * @ssid_len: SSID length
  1101. * Returns: 0 on success, -1 on failure
  1102. *
  1103. * This function is only needed for drivers that export MLME
  1104. * (management frame processing) to wpa_supplicant.
  1105. */
  1106. int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
  1107. /**
  1108. * set_bssid - Set BSSID
  1109. * @priv: Private driver interface data
  1110. * @bssid: BSSID
  1111. * Returns: 0 on success, -1 on failure
  1112. *
  1113. * This function is only needed for drivers that export MLME
  1114. * (management frame processing) to wpa_supplicant.
  1115. */
  1116. int (*set_bssid)(void *priv, const u8 *bssid);
  1117. /**
  1118. * send_mlme - Send management frame from MLME
  1119. * @priv: Private driver interface data
  1120. * @data: IEEE 802.11 management frame with IEEE 802.11 header
  1121. * @data_len: Size of the management frame
  1122. * Returns: 0 on success, -1 on failure
  1123. *
  1124. * This function is only needed for drivers that export MLME
  1125. * (management frame processing) to wpa_supplicant.
  1126. */
  1127. int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
  1128. /**
  1129. * mlme_add_sta - Add a STA entry into the driver/netstack
  1130. * @priv: Private driver interface data
  1131. * @addr: MAC address of the STA (e.g., BSSID of the AP)
  1132. * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
  1133. * format (one octet per rate, 1 = 0.5 Mbps)
  1134. * @supp_rates_len: Number of entries in supp_rates
  1135. * Returns: 0 on success, -1 on failure
  1136. *
  1137. * This function is only needed for drivers that export MLME
  1138. * (management frame processing) to wpa_supplicant. When the MLME code
  1139. * completes association with an AP, this function is called to
  1140. * configure the driver/netstack with a STA entry for data frame
  1141. * processing (TX rate control, encryption/decryption).
  1142. */
  1143. int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
  1144. size_t supp_rates_len);
  1145. /**
  1146. * mlme_remove_sta - Remove a STA entry from the driver/netstack
  1147. * @priv: Private driver interface data
  1148. * @addr: MAC address of the STA (e.g., BSSID of the AP)
  1149. * Returns: 0 on success, -1 on failure
  1150. *
  1151. * This function is only needed for drivers that export MLME
  1152. * (management frame processing) to wpa_supplicant.
  1153. */
  1154. int (*mlme_remove_sta)(void *priv, const u8 *addr);
  1155. /**
  1156. * update_ft_ies - Update FT (IEEE 802.11r) IEs
  1157. * @priv: Private driver interface data
  1158. * @md: Mobility domain (2 octets) (also included inside ies)
  1159. * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
  1160. * @ies_len: Length of FT IEs in bytes
  1161. * Returns: 0 on success, -1 on failure
  1162. *
  1163. * The supplicant uses this callback to let the driver know that keying
  1164. * material for FT is available and that the driver can use the
  1165. * provided IEs in the next message in FT authentication sequence.
  1166. *
  1167. * This function is only needed for driver that support IEEE 802.11r
  1168. * (Fast BSS Transition).
  1169. */
  1170. int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
  1171. size_t ies_len);
  1172. /**
  1173. * send_ft_action - Send FT Action frame (IEEE 802.11r)
  1174. * @priv: Private driver interface data
  1175. * @action: Action field value
  1176. * @target_ap: Target AP address
  1177. * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
  1178. * @ies_len: Length of FT IEs in bytes
  1179. * Returns: 0 on success, -1 on failure
  1180. *
  1181. * The supplicant uses this callback to request the driver to transmit
  1182. * an FT Action frame (action category 6) for over-the-DS fast BSS
  1183. * transition.
  1184. */
  1185. int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
  1186. const u8 *ies, size_t ies_len);
  1187. /**
  1188. * get_scan_results2 - Fetch the latest scan results
  1189. * @priv: private driver interface data
  1190. *
  1191. * Returns: Allocated buffer of scan results (caller is responsible for
  1192. * freeing the data structure) on success, NULL on failure
  1193. */
  1194. struct wpa_scan_results * (*get_scan_results2)(void *priv);
  1195. /**
  1196. * set_country - Set country
  1197. * @priv: Private driver interface data
  1198. * @alpha2: country to which to switch to
  1199. * Returns: 0 on success, -1 on failure
  1200. *
  1201. * This function is for drivers which support some form
  1202. * of setting a regulatory domain.
  1203. */
  1204. int (*set_country)(void *priv, const char *alpha2);
  1205. /**
  1206. * global_init - Global driver initialization
  1207. * Returns: Pointer to private data (global), %NULL on failure
  1208. *
  1209. * This optional function is called to initialize the driver wrapper
  1210. * for global data, i.e., data that applies to all interfaces. If this
  1211. * function is implemented, global_deinit() will also need to be
  1212. * implemented to free the private data. The driver will also likely
  1213. * use init2() function instead of init() to get the pointer to global
  1214. * data available to per-interface initializer.
  1215. */
  1216. void * (*global_init)(void);
  1217. /**
  1218. * global_deinit - Global driver deinitialization
  1219. * @priv: private driver global data from global_init()
  1220. *
  1221. * Terminate any global driver related functionality and free the
  1222. * global data structure.
  1223. */
  1224. void (*global_deinit)(void *priv);
  1225. /**
  1226. * init2 - Initialize driver interface (with global data)
  1227. * @ctx: context to be used when calling wpa_supplicant functions,
  1228. * e.g., wpa_supplicant_event()
  1229. * @ifname: interface name, e.g., wlan0
  1230. * @global_priv: private driver global data from global_init()
  1231. * Returns: Pointer to private data, %NULL on failure
  1232. *
  1233. * This function can be used instead of init() if the driver wrapper
  1234. * uses global data.
  1235. */
  1236. void * (*init2)(void *ctx, const char *ifname, void *global_priv);
  1237. /**
  1238. * get_interfaces - Get information about available interfaces
  1239. * @global_priv: private driver global data from global_init()
  1240. * Returns: Allocated buffer of interface information (caller is
  1241. * responsible for freeing the data structure) on success, NULL on
  1242. * failure
  1243. */
  1244. struct wpa_interface_info * (*get_interfaces)(void *global_priv);
  1245. /**
  1246. * scan2 - Request the driver to initiate scan
  1247. * @priv: private driver interface data
  1248. * @params: Scan parameters
  1249. *
  1250. * Returns: 0 on success, -1 on failure
  1251. *
  1252. * Once the scan results are ready, the driver should report scan
  1253. * results event for wpa_supplicant which will eventually request the
  1254. * results with wpa_driver_get_scan_results2().
  1255. */
  1256. int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
  1257. /**
  1258. * authenticate - Request driver to authenticate
  1259. * @priv: private driver interface data
  1260. * @params: authentication parameters
  1261. * Returns: 0 on success, -1 on failure
  1262. *
  1263. * This is an optional function that can be used with drivers that
  1264. * support separate authentication and association steps, i.e., when
  1265. * wpa_supplicant can act as the SME. If not implemented, associate()
  1266. * function is expected to take care of IEEE 802.11 authentication,
  1267. * too.
  1268. */
  1269. int (*authenticate)(void *priv,
  1270. struct wpa_driver_auth_params *params);
  1271. /**
  1272. * set_ap - Set Beacon and Probe Response information for AP mode
  1273. * @priv: Private driver interface data
  1274. * @params: Parameters to use in AP mode
  1275. *
  1276. * This function is used to configure Beacon template and/or extra IEs
  1277. * to add for Beacon and Probe Response frames for the driver in
  1278. * AP mode. The driver is responsible for building the full Beacon
  1279. * frame by concatenating the head part with TIM IE generated by the
  1280. * driver/firmware and finishing with the tail part. Depending on the
  1281. * driver architectue, this can be done either by using the full
  1282. * template or the set of additional IEs (e.g., WPS and P2P IE).
  1283. * Similarly, Probe Response processing depends on the driver design.
  1284. * If the driver (or firmware) takes care of replying to Probe Request
  1285. * frames, the extra IEs provided here needs to be added to the Probe
  1286. * Response frames.
  1287. *
  1288. * Returns: 0 on success, -1 on failure
  1289. */
  1290. int (*set_ap)(void *priv, struct wpa_driver_ap_params *params);
  1291. /**
  1292. * hapd_init - Initialize driver interface (hostapd only)
  1293. * @hapd: Pointer to hostapd context
  1294. * @params: Configuration for the driver wrapper
  1295. * Returns: Pointer to private data, %NULL on failure
  1296. *
  1297. * This function is used instead of init() or init2() when the driver
  1298. * wrapper is used with hostapd.
  1299. */
  1300. void * (*hapd_init)(struct hostapd_data *hapd,
  1301. struct wpa_init_params *params);
  1302. /**
  1303. * hapd_deinit - Deinitialize driver interface (hostapd only)
  1304. * @priv: Private driver interface data from hapd_init()
  1305. */
  1306. void (*hapd_deinit)(void *priv);
  1307. /**
  1308. * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
  1309. * @priv: Private driver interface data
  1310. * @params: BSS parameters
  1311. * Returns: 0 on success, -1 on failure
  1312. *
  1313. * This is an optional function to configure the kernel driver to
  1314. * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
  1315. * can be left undefined (set to %NULL) if IEEE 802.1X support is
  1316. * always enabled and the driver uses set_ap() to set WPA/RSN IE
  1317. * for Beacon frames.
  1318. */
  1319. int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
  1320. /**
  1321. * set_privacy - Enable/disable privacy (AP only)
  1322. * @priv: Private driver interface data
  1323. * @enabled: 1 = privacy enabled, 0 = disabled
  1324. * Returns: 0 on success, -1 on failure
  1325. *
  1326. * This is an optional function to configure privacy field in the
  1327. * kernel driver for Beacon frames. This can be left undefined (set to
  1328. * %NULL) if the driver uses the Beacon template from set_ap().
  1329. */
  1330. int (*set_privacy)(void *priv, int enabled);
  1331. /**
  1332. * get_seqnum - Fetch the current TSC/packet number (AP only)
  1333. * @ifname: The interface name (main or virtual)
  1334. * @priv: Private driver interface data
  1335. * @addr: MAC address of the station or %NULL for group keys
  1336. * @idx: Key index
  1337. * @seq: Buffer for returning the latest used TSC/packet number
  1338. * Returns: 0 on success, -1 on failure
  1339. *
  1340. * This function is used to fetch the last used TSC/packet number for
  1341. * a TKIP, CCMP, or BIP/IGTK key. It is mainly used with group keys, so
  1342. * there is no strict requirement on implementing support for unicast
  1343. * keys (i.e., addr != %NULL).
  1344. */
  1345. int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
  1346. int idx, u8 *seq);
  1347. /**
  1348. * flush - Flush all association stations (AP only)
  1349. * @priv: Private driver interface data
  1350. * Returns: 0 on success, -1 on failure
  1351. *
  1352. * This function requests the driver to disassociate all associated
  1353. * stations. This function does not need to be implemented if the
  1354. * driver does not process association frames internally.
  1355. */
  1356. int (*flush)(void *priv);
  1357. /**
  1358. * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
  1359. * @priv: Private driver interface data
  1360. * @elem: Information elements
  1361. * @elem_len: Length of the elem buffer in octets
  1362. * Returns: 0 on success, -1 on failure
  1363. *
  1364. * This is an optional function to add information elements in the
  1365. * kernel driver for Beacon and Probe Response frames. This can be left
  1366. * undefined (set to %NULL) if the driver uses the Beacon template from
  1367. * set_ap().
  1368. */
  1369. int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
  1370. /**
  1371. * read_sta_data - Fetch station data (AP only)
  1372. * @priv: Private driver interface data
  1373. * @data: Buffer for returning station information
  1374. * @addr: MAC address of the station
  1375. * Returns: 0 on success, -1 on failure
  1376. */
  1377. int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
  1378. const u8 *addr);
  1379. /**
  1380. * hapd_send_eapol - Send an EAPOL packet (AP only)
  1381. * @priv: private driver interface data
  1382. * @addr: Destination MAC address
  1383. * @data: EAPOL packet starting with IEEE 802.1X header
  1384. * @data_len: Length of the EAPOL packet in octets
  1385. * @encrypt: Whether the frame should be encrypted
  1386. * @own_addr: Source MAC address
  1387. * @flags: WPA_STA_* flags for the destination station
  1388. *
  1389. * Returns: 0 on success, -1 on failure
  1390. */
  1391. int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
  1392. size_t data_len, int encrypt,
  1393. const u8 *own_addr, u32 flags);
  1394. /**
  1395. * sta_deauth - Deauthenticate a station (AP only)
  1396. * @priv: Private driver interface data
  1397. * @own_addr: Source address and BSSID for the Deauthentication frame
  1398. * @addr: MAC address of the station to deauthenticate
  1399. * @reason: Reason code for the Deauthentiation frame
  1400. * Returns: 0 on success, -1 on failure
  1401. *
  1402. * This function requests a specific station to be deauthenticated and
  1403. * a Deauthentication frame to be sent to it.
  1404. */
  1405. int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
  1406. int reason);
  1407. /**
  1408. * sta_disassoc - Disassociate a station (AP only)
  1409. * @priv: Private driver interface data
  1410. * @own_addr: Source address and BSSID for the Disassociation frame
  1411. * @addr: MAC address of the station to disassociate
  1412. * @reason: Reason code for the Disassociation frame
  1413. * Returns: 0 on success, -1 on failure
  1414. *
  1415. * This function requests a specific station to be disassociated and
  1416. * a Disassociation frame to be sent to it.
  1417. */
  1418. int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
  1419. int reason);
  1420. /**
  1421. * sta_remove - Remove a station entry (AP only)
  1422. * @priv: Private driver interface data
  1423. * @addr: MAC address of the station to be removed
  1424. * Returns: 0 on success, -1 on failure
  1425. */
  1426. int (*sta_remove)(void *priv, const u8 *addr);
  1427. /**
  1428. * hapd_get_ssid - Get the current SSID (AP only)
  1429. * @priv: Private driver interface data
  1430. * @buf: Buffer for returning the SSID
  1431. * @len: Maximum length of the buffer
  1432. * Returns: Length of the SSID on success, -1 on failure
  1433. *
  1434. * This function need not be implemented if the driver uses Beacon
  1435. * template from set_ap() and does not reply to Probe Request frames.
  1436. */
  1437. int (*hapd_get_ssid)(void *priv, u8 *buf, int len);
  1438. /**
  1439. * hapd_set_ssid - Set SSID (AP only)
  1440. * @priv: Private driver interface data
  1441. * @buf: SSID
  1442. * @len: Length of the SSID in octets
  1443. * Returns: 0 on success, -1 on failure
  1444. */
  1445. int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
  1446. /**
  1447. * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
  1448. * @priv: Private driver interface data
  1449. * @enabled: 1 = countermeasures enabled, 0 = disabled
  1450. * Returns: 0 on success, -1 on failure
  1451. *
  1452. * This need not be implemented if the driver does not take care of
  1453. * association processing.
  1454. */
  1455. int (*hapd_set_countermeasures)(void *priv, int enabled);
  1456. /**
  1457. * sta_add - Add a station entry
  1458. * @priv: Private driver interface data
  1459. * @params: Station parameters
  1460. * Returns: 0 on success, -1 on failure
  1461. *
  1462. * This function is used to add a station entry to the driver once the
  1463. * station has completed association. This is only used if the driver
  1464. * does not take care of association processing.
  1465. */
  1466. int (*sta_add)(void *priv, struct hostapd_sta_add_params *params);
  1467. /**
  1468. * get_inact_sec - Get station inactivity duration (AP only)
  1469. * @priv: Private driver interface data
  1470. * @addr: Station address
  1471. * Returns: Number of seconds station has been inactive, -1 on failure
  1472. */
  1473. int (*get_inact_sec)(void *priv, const u8 *addr);
  1474. /**
  1475. * sta_clear_stats - Clear station statistics (AP only)
  1476. * @priv: Private driver interface data
  1477. * @addr: Station address
  1478. * Returns: 0 on success, -1 on failure
  1479. */
  1480. int (*sta_clear_stats)(void *priv, const u8 *addr);
  1481. /**
  1482. * set_freq - Set channel/frequency (AP only)
  1483. * @priv: Private driver interface data
  1484. * @freq: Channel parameters
  1485. * Returns: 0 on success, -1 on failure
  1486. */
  1487. int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
  1488. /**
  1489. * set_rts - Set RTS threshold
  1490. * @priv: Private driver interface data
  1491. * @rts: RTS threshold in octets
  1492. * Returns: 0 on success, -1 on failure
  1493. */
  1494. int (*set_rts)(void *priv, int rts);
  1495. /**
  1496. * set_frag - Set fragmentation threshold
  1497. * @priv: Private driver interface data
  1498. * @frag: Fragmentation threshold in octets
  1499. * Returns: 0 on success, -1 on failure
  1500. */
  1501. int (*set_frag)(void *priv, int frag);
  1502. /**
  1503. * sta_set_flags - Set station flags (AP only)
  1504. * @priv: Private driver interface data
  1505. * @addr: Station address
  1506. * @total_flags: Bitmap of all WPA_STA_* flags currently set
  1507. * @flags_or: Bitmap of WPA_STA_* flags to add
  1508. * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
  1509. * Returns: 0 on success, -1 on failure
  1510. */
  1511. int (*sta_set_flags)(void *priv, const u8 *addr,
  1512. int total_flags, int flags_or, int flags_and);
  1513. /**
  1514. * set_rate_sets - Set supported and basic rate sets (AP only)
  1515. * @priv: Private driver interface data
  1516. * @supp_rates: -1 terminated array of supported rates in 100 kbps
  1517. * @basic_rates: -1 terminated array of basic rates in 100 kbps
  1518. * @mode: hardware mode (HOSTAPD_MODE_*)
  1519. * Returns: 0 on success, -1 on failure
  1520. */
  1521. int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
  1522. int mode);
  1523. /**
  1524. * set_cts_protect - Set CTS protection mode (AP only)
  1525. * @priv: Private driver interface data
  1526. * @value: Whether CTS protection is enabled
  1527. * Returns: 0 on success, -1 on failure
  1528. */
  1529. int (*set_cts_protect)(void *priv, int value);
  1530. /**
  1531. * set_preamble - Set preamble mode (AP only)
  1532. * @priv: Private driver interface data
  1533. * @value: Whether short preamble is enabled
  1534. * Returns: 0 on success, -1 on failure
  1535. */
  1536. int (*set_preamble)(void *priv, int value);
  1537. /**
  1538. * set_short_slot_time - Set short slot time (AP only)
  1539. * @priv: Private driver interface data
  1540. * @value: Whether short slot time is enabled
  1541. * Returns: 0 on success, -1 on failure
  1542. */
  1543. int (*set_short_slot_time)(void *priv, int value);
  1544. /**
  1545. * set_tx_queue_params - Set TX queue parameters
  1546. * @priv: Private driver interface data
  1547. * @queue: Queue number (0 = VO, 1 = VI, 2 = BE, 3 = BK)
  1548. * @aifs: AIFS
  1549. * @cw_min: cwMin
  1550. * @cw_max: cwMax
  1551. * @burst_time: Maximum length for bursting in 0.1 msec units
  1552. */
  1553. int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
  1554. int cw_max, int burst_time);
  1555. /**
  1556. * valid_bss_mask - Validate BSSID mask
  1557. * @priv: Private driver interface data
  1558. * @addr: Address
  1559. * @mask: Mask
  1560. * Returns: 0 if mask is valid, -1 if mask is not valid, 1 if mask can
  1561. * be used, but the main interface address must be the first address in
  1562. * the block if mask is applied
  1563. */
  1564. int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
  1565. /**
  1566. * if_add - Add a virtual interface
  1567. * @priv: Private driver interface data
  1568. * @type: Interface type
  1569. * @ifname: Interface name for the new virtual interface
  1570. * @addr: Local address to use for the interface or %NULL to use the
  1571. * parent interface address
  1572. * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
  1573. * @drv_priv: Pointer for overwriting the driver context or %NULL if
  1574. * not allowed (applies only to %WPA_IF_AP_BSS type)
  1575. * @force_ifname: Buffer for returning an interface name that the
  1576. * driver ended up using if it differs from the requested ifname
  1577. * @if_addr: Buffer for returning the allocated interface address
  1578. * (this may differ from the requested addr if the driver cannot
  1579. * change interface address)
  1580. * @bridge: Bridge interface to use or %NULL if no bridge configured
  1581. * Returns: 0 on success, -1 on failure
  1582. */
  1583. int (*if_add)(void *priv, enum wpa_driver_if_type type,
  1584. const char *ifname, const u8 *addr, void *bss_ctx,
  1585. void **drv_priv, char *force_ifname, u8 *if_addr,
  1586. const char *bridge);
  1587. /**
  1588. * if_remove - Remove a virtual interface
  1589. * @priv: Private driver interface data
  1590. * @type: Interface type
  1591. * @ifname: Interface name of the virtual interface to be removed
  1592. * Returns: 0 on success, -1 on failure
  1593. */
  1594. int (*if_remove)(void *priv, enum wpa_driver_if_type type,
  1595. const char *ifname);
  1596. /**
  1597. * set_sta_vlan - Bind a station into a specific interface (AP only)
  1598. * @priv: Private driver interface data
  1599. * @ifname: Interface (main or virtual BSS or VLAN)
  1600. * @addr: MAC address of the associated station
  1601. * @vlan_id: VLAN ID
  1602. * Returns: 0 on success, -1 on failure
  1603. *
  1604. * This function is used to bind a station to a specific virtual
  1605. * interface. It is only used if when virtual interfaces are supported,
  1606. * e.g., to assign stations to different VLAN interfaces based on
  1607. * information from a RADIUS server. This allows separate broadcast
  1608. * domains to be used with a single BSS.
  1609. */
  1610. int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
  1611. int vlan_id);
  1612. /**
  1613. * commit - Optional commit changes handler (AP only)
  1614. * @priv: driver private data
  1615. * Returns: 0 on success, -1 on failure
  1616. *
  1617. * This optional handler function can be registered if the driver
  1618. * interface implementation needs to commit changes (e.g., by setting
  1619. * network interface up) at the end of initial configuration. If set,
  1620. * this handler will be called after initial setup has been completed.
  1621. */
  1622. int (*commit)(void *priv);
  1623. /**
  1624. * send_ether - Send an ethernet packet (AP only)
  1625. * @priv: private driver interface data
  1626. * @dst: Destination MAC address
  1627. * @src: Source MAC address
  1628. * @proto: Ethertype
  1629. * @data: EAPOL packet starting with IEEE 802.1X header
  1630. * @data_len: Length of the EAPOL packet in octets
  1631. * Returns: 0 on success, -1 on failure
  1632. */
  1633. int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
  1634. const u8 *data, size_t data_len);
  1635. /**
  1636. * set_radius_acl_auth - Notification of RADIUS ACL change
  1637. * @priv: Private driver interface data
  1638. * @mac: MAC address of the station
  1639. * @accepted: Whether the station was accepted
  1640. * @session_timeout: Session timeout for the station
  1641. * Returns: 0 on success, -1 on failure
  1642. */
  1643. int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
  1644. u32 session_timeout);
  1645. /**
  1646. * set_radius_acl_expire - Notification of RADIUS ACL expiration
  1647. * @priv: Private driver interface data
  1648. * @mac: MAC address of the station
  1649. * Returns: 0 on success, -1 on failure
  1650. */
  1651. int (*set_radius_acl_expire)(void *priv, const u8 *mac);
  1652. /**
  1653. * set_ht_params - Set HT parameters (AP only)
  1654. * @priv: Private driver interface data
  1655. * @ht_capab: HT Capabilities IE
  1656. * @ht_capab_len: Length of ht_capab in octets
  1657. * @ht_oper: HT Operation IE
  1658. * @ht_oper_len: Length of ht_oper in octets
  1659. * Returns: 0 on success, -1 on failure
  1660. */
  1661. int (*set_ht_params)(void *priv,
  1662. const u8 *ht_capab, size_t ht_capab_len,
  1663. const u8 *ht_oper, size_t ht_oper_len);
  1664. /**
  1665. * set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
  1666. * @priv: Private driver interface data
  1667. * @beacon: WPS IE(s) for Beacon frames or %NULL to remove extra IE(s)
  1668. * @proberesp: WPS IE(s) for Probe Response frames or %NULL to remove
  1669. * extra IE(s)
  1670. * @assocresp: WPS IE(s) for (Re)Association Response frames or %NULL
  1671. * to remove extra IE(s)
  1672. * Returns: 0 on success, -1 on failure
  1673. *
  1674. * This is an optional function to add WPS IE in the kernel driver for
  1675. * Beacon and Probe Response frames. This can be left undefined (set
  1676. * to %NULL) if the driver uses the Beacon template from set_ap()
  1677. * and does not process Probe Request frames. If the driver takes care
  1678. * of (Re)Association frame processing, the assocresp buffer includes
  1679. * WPS IE(s) that need to be added to (Re)Association Response frames
  1680. * whenever a (Re)Association Request frame indicated use of WPS.
  1681. *
  1682. * This will also be used to add P2P IE(s) into Beacon/Probe Response
  1683. * frames when operating as a GO. The driver is responsible for adding
  1684. * timing related attributes (e.g., NoA) in addition to the IEs
  1685. * included here by appending them after these buffers. This call is
  1686. * also used to provide Probe Response IEs for P2P Listen state
  1687. * operations for drivers that generate the Probe Response frames
  1688. * internally.
  1689. */
  1690. int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
  1691. const struct wpabuf *proberesp,
  1692. const struct wpabuf *assocresp);
  1693. /**
  1694. * set_supp_port - Set IEEE 802.1X Supplicant Port status
  1695. * @priv: Private driver interface data
  1696. * @authorized: Whether the port is authorized
  1697. * Returns: 0 on success, -1 on failure
  1698. */
  1699. int (*set_supp_port)(void *priv, int authorized);
  1700. /**
  1701. * set_wds_sta - Bind a station into a 4-address WDS (AP only)
  1702. * @priv: Private driver interface data
  1703. * @addr: MAC address of the associated station
  1704. * @aid: Association ID
  1705. * @val: 1 = bind to 4-address WDS; 0 = unbind
  1706. * @bridge_ifname: Bridge interface to use for the WDS station or %NULL
  1707. * to indicate that bridge is not to be used
  1708. * Returns: 0 on success, -1 on failure
  1709. */
  1710. int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
  1711. const char *bridge_ifname);
  1712. /**
  1713. * send_action - Transmit an Action frame
  1714. * @priv: Private driver interface data
  1715. * @freq: Frequency (in MHz) of the channel
  1716. * @wait: Time to wait off-channel for a response (in ms), or zero
  1717. * @dst: Destination MAC address (Address 1)
  1718. * @src: Source MAC address (Address 2)
  1719. * @bssid: BSSID (Address 3)
  1720. * @data: Frame body
  1721. * @data_len: data length in octets
  1722. * Returns: 0 on success, -1 on failure
  1723. *
  1724. * This command can be used to request the driver to transmit an action
  1725. * frame to the specified destination.
  1726. *
  1727. * If the %WPA_DRIVER_FLAGS_OFFCHANNEL_TX flag is set, the frame will
  1728. * be transmitted on the given channel and the device will wait for a
  1729. * response on that channel for the given wait time.
  1730. *
  1731. * If the flag is not set, the wait time will be ignored. In this case,
  1732. * if a remain-on-channel duration is in progress, the frame must be
  1733. * transmitted on that channel; alternatively the frame may be sent on
  1734. * the current operational channel (if in associated state in station
  1735. * mode or while operating as an AP.)
  1736. */
  1737. int (*send_action)(void *priv, unsigned int freq, unsigned int wait,
  1738. const u8 *dst, const u8 *src, const u8 *bssid,
  1739. const u8 *data, size_t data_len);
  1740. /**
  1741. * send_action_cancel_wait - Cancel action frame TX wait
  1742. * @priv: Private driver interface data
  1743. *
  1744. * This command cancels the wait time associated with sending an action
  1745. * frame. It is only available when %WPA_DRIVER_FLAGS_OFFCHANNEL_TX is
  1746. * set in the driver flags.
  1747. */
  1748. void (*send_action_cancel_wait)(void *priv);
  1749. /**
  1750. * remain_on_channel - Remain awake on a channel
  1751. * @priv: Private driver interface data
  1752. * @freq: Frequency (in MHz) of the channel
  1753. * @duration: Duration in milliseconds
  1754. * Returns: 0 on success, -1 on failure
  1755. *
  1756. * This command is used to request the driver to remain awake on the
  1757. * specified channel for the specified duration and report received
  1758. * Action frames with EVENT_RX_ACTION events. Optionally, received
  1759. * Probe Request frames may also be requested to be reported by calling
  1760. * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
  1761. *
  1762. * The driver may not be at the requested channel when this function
  1763. * returns, i.e., the return code is only indicating whether the
  1764. * request was accepted. The caller will need to wait until the
  1765. * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
  1766. * completed the channel change. This may take some time due to other
  1767. * need for the radio and the caller should be prepared to timing out
  1768. * its wait since there are no guarantees on when this request can be
  1769. * executed.
  1770. */
  1771. int (*remain_on_channel)(void *priv, unsigned int freq,
  1772. unsigned int duration);
  1773. /**
  1774. * cancel_remain_on_channel - Cancel remain-on-channel operation
  1775. * @priv: Private driver interface data
  1776. *
  1777. * This command can be used to cancel a remain-on-channel operation
  1778. * before its originally requested duration has passed. This could be
  1779. * used, e.g., when remain_on_channel() is used to request extra time
  1780. * to receive a response to an Action frame and the response is
  1781. * received when there is still unneeded time remaining on the
  1782. * remain-on-channel operation.
  1783. */
  1784. int (*cancel_remain_on_channel)(void *priv);
  1785. /**
  1786. * probe_req_report - Request Probe Request frames to be indicated
  1787. * @priv: Private driver interface data
  1788. * @report: Whether to report received Probe Request frames
  1789. * Returns: 0 on success, -1 on failure (or if not supported)
  1790. *
  1791. * This command can be used to request the driver to indicate when
  1792. * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
  1793. * Since this operation may require extra resources, e.g., due to less
  1794. * optimal hardware/firmware RX filtering, many drivers may disable
  1795. * Probe Request reporting at least in station mode. This command is
  1796. * used to notify the driver when the Probe Request frames need to be
  1797. * reported, e.g., during remain-on-channel operations.
  1798. */
  1799. int (*probe_req_report)(void *priv, int report);
  1800. /**
  1801. * disable_11b_rates - Set whether IEEE 802.11b rates are used for TX
  1802. * @priv: Private driver interface data
  1803. * @disabled: Whether IEEE 802.11b rates are disabled
  1804. * Returns: 0 on success, -1 on failure (or if not supported)
  1805. *
  1806. * This command is used to disable IEEE 802.11b rates (1, 2, 5.5, and
  1807. * 11 Mbps) as TX rates for data and management frames. This can be
  1808. * used to optimize channel use when there is no need to support IEEE
  1809. * 802.11b-only devices.
  1810. */
  1811. int (*disable_11b_rates)(void *priv, int disabled);
  1812. /**
  1813. * deinit_ap - Deinitialize AP mode
  1814. * @priv: Private driver interface data
  1815. * Returns: 0 on success, -1 on failure (or if not supported)
  1816. *
  1817. * This optional function can be used to disable AP mode related
  1818. * configuration and change the driver mode to station mode to allow
  1819. * normal station operations like scanning to be completed.
  1820. */
  1821. int (*deinit_ap)(void *priv);
  1822. /**
  1823. * suspend - Notification on system suspend/hibernate event
  1824. * @priv: Private driver interface data
  1825. */
  1826. void (*suspend)(void *priv);
  1827. /**
  1828. * resume - Notification on system resume/thaw event
  1829. * @priv: Private driver interface data
  1830. */
  1831. void (*resume)(void *priv);
  1832. /**
  1833. * signal_monitor - Set signal monitoring parameters
  1834. * @priv: Private driver interface data
  1835. * @threshold: Threshold value for signal change events; 0 = disabled
  1836. * @hysteresis: Minimum change in signal strength before indicating a
  1837. * new event
  1838. * Returns: 0 on success, -1 on failure (or if not supported)
  1839. *
  1840. * This function can be used to configure monitoring of signal strength
  1841. * with the current AP. Whenever signal strength drops below the
  1842. * %threshold value or increases above it, EVENT_SIGNAL_CHANGE event
  1843. * should be generated assuming the signal strength has changed at
  1844. * least %hysteresis from the previously indicated signal change event.
  1845. */
  1846. int (*signal_monitor)(void *priv, int threshold, int hysteresis);
  1847. /**
  1848. * send_frame - Send IEEE 802.11 frame (testing use only)
  1849. * @priv: Private driver interface data
  1850. * @data: IEEE 802.11 frame with IEEE 802.11 header
  1851. * @data_len: Size of the frame
  1852. * @encrypt: Whether to encrypt the frame (if keys are set)
  1853. * Returns: 0 on success, -1 on failure
  1854. *
  1855. * This function is only used for debugging purposes and is not
  1856. * required to be implemented for normal operations.
  1857. */
  1858. int (*send_frame)(void *priv, const u8 *data, size_t data_len,
  1859. int encrypt);
  1860. /**
  1861. * shared_freq - Get operating frequency of shared interface(s)
  1862. * @priv: Private driver interface data
  1863. * Returns: Operating frequency in MHz, 0 if no shared operation in
  1864. * use, or -1 on failure
  1865. *
  1866. * This command can be used to request the current operating frequency
  1867. * of any virtual interface that shares the same radio to provide
  1868. * information for channel selection for other virtual interfaces.
  1869. */
  1870. int (*shared_freq)(void *priv);
  1871. /**
  1872. * get_noa - Get current Notice of Absence attribute payload
  1873. * @priv: Private driver interface data
  1874. * @buf: Buffer for returning NoA
  1875. * @buf_len: Buffer length in octets
  1876. * Returns: Number of octets used in buf, 0 to indicate no NoA is being
  1877. * advertized, or -1 on failure
  1878. *
  1879. * This function is used to fetch the current Notice of Absence
  1880. * attribute value from GO.
  1881. */
  1882. int (*get_noa)(void *priv, u8 *buf, size_t buf_len);
  1883. /**
  1884. * set_noa - Set Notice of Absence parameters for GO (testing)
  1885. * @priv: Private driver interface data
  1886. * @count: Count
  1887. * @start: Start time in ms from next TBTT
  1888. * @duration: Duration in ms
  1889. * Returns: 0 on success or -1 on failure
  1890. *
  1891. * This function is used to set Notice of Absence parameters for GO. It
  1892. * is used only for testing. To disable NoA, all parameters are set to
  1893. * 0.
  1894. */
  1895. int (*set_noa)(void *priv, u8 count, int start, int duration);
  1896. /**
  1897. * set_p2p_powersave - Set P2P power save options
  1898. * @priv: Private driver interface data
  1899. * @legacy_ps: 0 = disable, 1 = enable, 2 = maximum PS, -1 = no change
  1900. * @opp_ps: 0 = disable, 1 = enable, -1 = no change
  1901. * @ctwindow: 0.. = change (msec), -1 = no change
  1902. * Returns: 0 on success or -1 on failure
  1903. */
  1904. int (*set_p2p_powersave)(void *priv, int legacy_ps, int opp_ps,
  1905. int ctwindow);
  1906. /**
  1907. * ampdu - Enable/disable aggregation
  1908. * @priv: Private driver interface data
  1909. * @ampdu: 1/0 = enable/disable A-MPDU aggregation
  1910. * Returns: 0 on success or -1 on failure
  1911. */
  1912. int (*ampdu)(void *priv, int ampdu);
  1913. /**
  1914. * set_intra_bss - Enables/Disables intra BSS bridging
  1915. */
  1916. int (*set_intra_bss)(void *priv, int enabled);
  1917. /**
  1918. * get_radio_name - Get physical radio name for the device
  1919. * @priv: Private driver interface data
  1920. * Returns: Radio name or %NULL if not known
  1921. *
  1922. * The returned data must not be modified by the caller. It is assumed
  1923. * that any interface that has the same radio name as another is
  1924. * sharing the same physical radio. This information can be used to
  1925. * share scan results etc. information between the virtual interfaces
  1926. * to speed up various operations.
  1927. */
  1928. const char * (*get_radio_name)(void *priv);
  1929. /**
  1930. * p2p_find - Start P2P Device Discovery
  1931. * @priv: Private driver interface data
  1932. * @timeout: Timeout for find operation in seconds or 0 for no timeout
  1933. * @type: Device Discovery type (enum p2p_discovery_type)
  1934. * Returns: 0 on success, -1 on failure
  1935. *
  1936. * This function is only used if the driver implements P2P management,
  1937. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  1938. * struct wpa_driver_capa.
  1939. */
  1940. int (*p2p_find)(void *priv, unsigned int timeout, int type);
  1941. /**
  1942. * p2p_stop_find - Stop P2P Device Discovery
  1943. * @priv: Private driver interface data
  1944. * Returns: 0 on success, -1 on failure
  1945. *
  1946. * This function is only used if the driver implements P2P management,
  1947. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  1948. * struct wpa_driver_capa.
  1949. */
  1950. int (*p2p_stop_find)(void *priv);
  1951. /**
  1952. * p2p_listen - Start P2P Listen state for specified duration
  1953. * @priv: Private driver interface data
  1954. * @timeout: Listen state duration in milliseconds
  1955. * Returns: 0 on success, -1 on failure
  1956. *
  1957. * This function can be used to request the P2P module to keep the
  1958. * device discoverable on the listen channel for an extended set of
  1959. * time. At least in its current form, this is mainly used for testing
  1960. * purposes and may not be of much use for normal P2P operations.
  1961. *
  1962. * This function is only used if the driver implements P2P management,
  1963. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  1964. * struct wpa_driver_capa.
  1965. */
  1966. int (*p2p_listen)(void *priv, unsigned int timeout);
  1967. /**
  1968. * p2p_connect - Start P2P group formation (GO negotiation)
  1969. * @priv: Private driver interface data
  1970. * @peer_addr: MAC address of the peer P2P client
  1971. * @wps_method: enum p2p_wps_method value indicating config method
  1972. * @go_intent: Local GO intent value (1..15)
  1973. * @own_interface_addr: Intended interface address to use with the
  1974. * group
  1975. * @force_freq: The only allowed channel frequency in MHz or 0
  1976. * @persistent_group: Whether to create persistent group
  1977. * Returns: 0 on success, -1 on failure
  1978. *
  1979. * This function is only used if the driver implements P2P management,
  1980. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  1981. * struct wpa_driver_capa.
  1982. */
  1983. int (*p2p_connect)(void *priv, const u8 *peer_addr, int wps_method,
  1984. int go_intent, const u8 *own_interface_addr,
  1985. unsigned int force_freq, int persistent_group);
  1986. /**
  1987. * wps_success_cb - Report successfully completed WPS provisioning
  1988. * @priv: Private driver interface data
  1989. * @peer_addr: Peer address
  1990. * Returns: 0 on success, -1 on failure
  1991. *
  1992. * This function is used to report successfully completed WPS
  1993. * provisioning during group formation in both GO/Registrar and
  1994. * client/Enrollee roles.
  1995. *
  1996. * This function is only used if the driver implements P2P management,
  1997. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  1998. * struct wpa_driver_capa.
  1999. */
  2000. int (*wps_success_cb)(void *priv, const u8 *peer_addr);
  2001. /**
  2002. * p2p_group_formation_failed - Report failed WPS provisioning
  2003. * @priv: Private driver interface data
  2004. * Returns: 0 on success, -1 on failure
  2005. *
  2006. * This function is used to report failed group formation. This can
  2007. * happen either due to failed WPS provisioning or due to 15 second
  2008. * timeout during the provisioning phase.
  2009. *
  2010. * This function is only used if the driver implements P2P management,
  2011. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2012. * struct wpa_driver_capa.
  2013. */
  2014. int (*p2p_group_formation_failed)(void *priv);
  2015. /**
  2016. * p2p_set_params - Set P2P parameters
  2017. * @priv: Private driver interface data
  2018. * @params: P2P parameters
  2019. * Returns: 0 on success, -1 on failure
  2020. *
  2021. * This function is only used if the driver implements P2P management,
  2022. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2023. * struct wpa_driver_capa.
  2024. */
  2025. int (*p2p_set_params)(void *priv, const struct p2p_params *params);
  2026. /**
  2027. * p2p_prov_disc_req - Send Provision Discovery Request
  2028. * @priv: Private driver interface data
  2029. * @peer_addr: MAC address of the peer P2P client
  2030. * @config_methods: WPS Config Methods value (only one bit set)
  2031. * Returns: 0 on success, -1 on failure
  2032. *
  2033. * This function can be used to request a discovered P2P peer to
  2034. * display a PIN (config_methods = WPS_CONFIG_DISPLAY) or be prepared
  2035. * to enter a PIN from us (config_methods = WPS_CONFIG_KEYPAD). The
  2036. * Provision Discovery Request frame is transmitted once immediately
  2037. * and if no response is received, the frame will be sent again
  2038. * whenever the target device is discovered during device dsicovery
  2039. * (start with a p2p_find() call). Response from the peer is indicated
  2040. * with the EVENT_P2P_PROV_DISC_RESPONSE event.
  2041. *
  2042. * This function is only used if the driver implements P2P management,
  2043. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2044. * struct wpa_driver_capa.
  2045. */
  2046. int (*p2p_prov_disc_req)(void *priv, const u8 *peer_addr,
  2047. u16 config_methods);
  2048. /**
  2049. * p2p_sd_request - Schedule a service discovery query
  2050. * @priv: Private driver interface data
  2051. * @dst: Destination peer or %NULL to apply for all peers
  2052. * @tlvs: P2P Service Query TLV(s)
  2053. * Returns: Reference to the query or 0 on failure
  2054. *
  2055. * Response to the query is indicated with the
  2056. * EVENT_P2P_SD_RESPONSE driver event.
  2057. *
  2058. * This function is only used if the driver implements P2P management,
  2059. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2060. * struct wpa_driver_capa.
  2061. */
  2062. u64 (*p2p_sd_request)(void *priv, const u8 *dst,
  2063. const struct wpabuf *tlvs);
  2064. /**
  2065. * p2p_sd_cancel_request - Cancel a pending service discovery query
  2066. * @priv: Private driver interface data
  2067. * @req: Query reference from p2p_sd_request()
  2068. * Returns: 0 on success, -1 on failure
  2069. *
  2070. * This function is only used if the driver implements P2P management,
  2071. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2072. * struct wpa_driver_capa.
  2073. */
  2074. int (*p2p_sd_cancel_request)(void *priv, u64 req);
  2075. /**
  2076. * p2p_sd_response - Send response to a service discovery query
  2077. * @priv: Private driver interface data
  2078. * @freq: Frequency from EVENT_P2P_SD_REQUEST event
  2079. * @dst: Destination address from EVENT_P2P_SD_REQUEST event
  2080. * @dialog_token: Dialog token from EVENT_P2P_SD_REQUEST event
  2081. * @resp_tlvs: P2P Service Response TLV(s)
  2082. * Returns: 0 on success, -1 on failure
  2083. *
  2084. * This function is called as a response to the request indicated with
  2085. * the EVENT_P2P_SD_REQUEST driver event.
  2086. *
  2087. * This function is only used if the driver implements P2P management,
  2088. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2089. * struct wpa_driver_capa.
  2090. */
  2091. int (*p2p_sd_response)(void *priv, int freq, const u8 *dst,
  2092. u8 dialog_token,
  2093. const struct wpabuf *resp_tlvs);
  2094. /**
  2095. * p2p_service_update - Indicate a change in local services
  2096. * @priv: Private driver interface data
  2097. * Returns: 0 on success, -1 on failure
  2098. *
  2099. * This function needs to be called whenever there is a change in
  2100. * availability of the local services. This will increment the
  2101. * Service Update Indicator value which will be used in SD Request and
  2102. * Response frames.
  2103. *
  2104. * This function is only used if the driver implements P2P management,
  2105. * i.e., if it sets WPA_DRIVER_FLAGS_P2P_MGMT in
  2106. * struct wpa_driver_capa.
  2107. */
  2108. int (*p2p_service_update)(void *priv);
  2109. /**
  2110. * p2p_reject - Reject peer device (explicitly block connections)
  2111. * @priv: Private driver interface data
  2112. * @addr: MAC address of the peer
  2113. * Returns: 0 on success, -1 on failure
  2114. */
  2115. int (*p2p_reject)(void *priv, const u8 *addr);
  2116. /**
  2117. * p2p_invite - Invite a P2P Device into a group
  2118. * @priv: Private driver interface data
  2119. * @peer: Device Address of the peer P2P Device
  2120. * @role: Local role in the group
  2121. * @bssid: Group BSSID or %NULL if not known
  2122. * @ssid: Group SSID
  2123. * @ssid_len: Length of ssid in octets
  2124. * @go_dev_addr: Forced GO Device Address or %NULL if none
  2125. * @persistent_group: Whether this is to reinvoke a persistent group
  2126. * Returns: 0 on success, -1 on failure
  2127. */
  2128. int (*p2p_invite)(void *priv, const u8 *peer, int role,
  2129. const u8 *bssid, const u8 *ssid, size_t ssid_len,
  2130. const u8 *go_dev_addr, int persistent_group);
  2131. /**
  2132. * send_tdls_mgmt - for sending TDLS management packets
  2133. * @priv: private driver interface data
  2134. * @dst: Destination (peer) MAC address
  2135. * @action_code: TDLS action code for the mssage
  2136. * @dialog_token: Dialog Token to use in the message (if needed)
  2137. * @status_code: Status Code or Reason Code to use (if needed)
  2138. * @buf: TDLS IEs to add to the message
  2139. * @len: Length of buf in octets
  2140. * Returns: 0 on success, -1 on failure
  2141. *
  2142. * This optional function can be used to send packet to driver which is
  2143. * responsible for receiving and sending all TDLS packets.
  2144. */
  2145. int (*send_tdls_mgmt)(void *priv, const u8 *dst, u8 action_code,
  2146. u8 dialog_token, u16 status_code,
  2147. const u8 *buf, size_t len);
  2148. int (*tdls_oper)(void *priv, enum tdls_oper oper, const u8 *peer);
  2149. /**
  2150. * signal_poll - Get current connection information
  2151. * @priv: Private driver interface data
  2152. * @signal_info: Connection info structure
  2153. */
  2154. int (*signal_poll)(void *priv, struct wpa_signal_info *signal_info);
  2155. /**
  2156. * set_authmode - Set authentication algorithm(s) for static WEP
  2157. * @priv: Private driver interface data
  2158. * @authmode: 1=Open System, 2=Shared Key, 3=both
  2159. * Returns: 0 on success, -1 on failure
  2160. *
  2161. * This function can be used to set authentication algorithms for AP
  2162. * mode when static WEP is used. If the driver uses user space MLME/SME
  2163. * implementation, there is no need to implement this function.
  2164. */
  2165. int (*set_authmode)(void *priv, int authmode);
  2166. /**
  2167. * set_rekey_info - Set rekey information
  2168. * @priv: Private driver interface data
  2169. * @kek: Current KEK
  2170. * @kck: Current KCK
  2171. * @replay_ctr: Current EAPOL-Key Replay Counter
  2172. *
  2173. * This optional function can be used to provide information for the
  2174. * driver/firmware to process EAPOL-Key frames in Group Key Handshake
  2175. * while the host (including wpa_supplicant) is sleeping.
  2176. */
  2177. void (*set_rekey_info)(void *priv, const u8 *kek, const u8 *kck,
  2178. const u8 *replay_ctr);
  2179. /**
  2180. * sta_assoc - Station association indication
  2181. * @priv: Private driver interface data
  2182. * @own_addr: Source address and BSSID for association frame
  2183. * @addr: MAC address of the station to associate
  2184. * @reassoc: flag to indicate re-association
  2185. * @status: association response status code
  2186. * @ie: assoc response ie buffer
  2187. * @len: ie buffer length
  2188. * Returns: 0 on success, -1 on failure
  2189. *
  2190. * This function indicates the driver to send (Re)Association
  2191. * Response frame to the station.
  2192. */
  2193. int (*sta_assoc)(void *priv, const u8 *own_addr, const u8 *addr,
  2194. int reassoc, u16 status, const u8 *ie, size_t len);
  2195. /**
  2196. * sta_auth - Station authentication indication
  2197. * @priv: Private driver interface data
  2198. * @own_addr: Source address and BSSID for authentication frame
  2199. * @addr: MAC address of the station to associate
  2200. * @seq: authentication sequence number
  2201. * @status: authentication response status code
  2202. * @ie: authentication frame ie buffer
  2203. * @len: ie buffer length
  2204. *
  2205. * This function indicates the driver to send Authentication frame
  2206. * to the station.
  2207. */
  2208. int (*sta_auth)(void *priv, const u8 *own_addr, const u8 *addr,
  2209. u16 seq, u16 status, const u8 *ie, size_t len);
  2210. /**
  2211. * add_tspec - Add traffic stream
  2212. * @priv: Private driver interface data
  2213. * @addr: MAC address of the station to associate
  2214. * @tspec_ie: tspec ie buffer
  2215. * @tspec_ielen: tspec ie length
  2216. * Returns: 0 on success, -1 on failure
  2217. *
  2218. * This function adds the traffic steam for the station
  2219. * and fills the medium_time in tspec_ie.
  2220. */
  2221. int (*add_tspec)(void *priv, const u8 *addr, u8 *tspec_ie,
  2222. size_t tspec_ielen);
  2223. /**
  2224. * add_sta_node - Add a station node in the driver
  2225. * @priv: Private driver interface data
  2226. * @addr: MAC address of the station to add
  2227. * @auth_alg: authentication algorithm used by the station
  2228. * Returns: 0 on success, -1 on failure
  2229. *
  2230. * This function adds the station node in the driver, when
  2231. * the station gets added by FT-over-DS.
  2232. */
  2233. int (*add_sta_node)(void *priv, const u8 *addr, u16 auth_alg);
  2234. /**
  2235. * sched_scan - Request the driver to initiate scheduled scan
  2236. * @priv: Private driver interface data
  2237. * @params: Scan parameters
  2238. * @interval: Interval between scan cycles in milliseconds
  2239. * Returns: 0 on success, -1 on failure
  2240. *
  2241. * This operation should be used for scheduled scan offload to
  2242. * the hardware. Every time scan results are available, the
  2243. * driver should report scan results event for wpa_supplicant
  2244. * which will eventually request the results with
  2245. * wpa_driver_get_scan_results2(). This operation is optional
  2246. * and if not provided or if it returns -1, we fall back to
  2247. * normal host-scheduled scans.
  2248. */
  2249. int (*sched_scan)(void *priv, struct wpa_driver_scan_params *params,
  2250. u32 interval);
  2251. /**
  2252. * stop_sched_scan - Request the driver to stop a scheduled scan
  2253. * @priv: Private driver interface data
  2254. * Returns: 0 on success, -1 on failure
  2255. *
  2256. * This should cause the scheduled scan to be stopped and
  2257. * results should stop being sent. Must be supported if
  2258. * sched_scan is supported.
  2259. */
  2260. int (*stop_sched_scan)(void *priv);
  2261. };
  2262. /**
  2263. * enum wpa_event_type - Event type for wpa_supplicant_event() calls
  2264. */
  2265. enum wpa_event_type {
  2266. /**
  2267. * EVENT_ASSOC - Association completed
  2268. *
  2269. * This event needs to be delivered when the driver completes IEEE
  2270. * 802.11 association or reassociation successfully.
  2271. * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
  2272. * after this event has been generated. In addition, optional
  2273. * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
  2274. * more information about the association. If the driver interface gets
  2275. * both of these events at the same time, it can also include the
  2276. * assoc_info data in EVENT_ASSOC call.
  2277. */
  2278. EVENT_ASSOC,
  2279. /**
  2280. * EVENT_DISASSOC - Association lost
  2281. *
  2282. * This event should be called when association is lost either due to
  2283. * receiving deauthenticate or disassociate frame from the AP or when
  2284. * sending either of these frames to the current AP. If the driver
  2285. * supports separate deauthentication event, EVENT_DISASSOC should only
  2286. * be used for disassociation and EVENT_DEAUTH for deauthentication.
  2287. * In AP mode, union wpa_event_data::disassoc_info is required.
  2288. */
  2289. EVENT_DISASSOC,
  2290. /**
  2291. * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
  2292. *
  2293. * This event must be delivered when a Michael MIC error is detected by
  2294. * the local driver. Additional data for event processing is
  2295. * provided with union wpa_event_data::michael_mic_failure. This
  2296. * information is used to request new encyption key and to initiate
  2297. * TKIP countermeasures if needed.
  2298. */
  2299. EVENT_MICHAEL_MIC_FAILURE,
  2300. /**
  2301. * EVENT_SCAN_RESULTS - Scan results available
  2302. *
  2303. * This event must be called whenever scan results are available to be
  2304. * fetched with struct wpa_driver_ops::get_scan_results(). This event
  2305. * is expected to be used some time after struct wpa_driver_ops::scan()
  2306. * is called. If the driver provides an unsolicited event when the scan
  2307. * has been completed, this event can be used to trigger
  2308. * EVENT_SCAN_RESULTS call. If such event is not available from the
  2309. * driver, the driver wrapper code is expected to use a registered
  2310. * timeout to generate EVENT_SCAN_RESULTS call after the time that the
  2311. * scan is expected to be completed. Optional information about
  2312. * completed scan can be provided with union wpa_event_data::scan_info.
  2313. */
  2314. EVENT_SCAN_RESULTS,
  2315. /**
  2316. * EVENT_ASSOCINFO - Report optional extra information for association
  2317. *
  2318. * This event can be used to report extra association information for
  2319. * EVENT_ASSOC processing. This extra information includes IEs from
  2320. * association frames and Beacon/Probe Response frames in union
  2321. * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
  2322. * EVENT_ASSOC. Alternatively, the driver interface can include
  2323. * assoc_info data in the EVENT_ASSOC call if it has all the
  2324. * information available at the same point.
  2325. */
  2326. EVENT_ASSOCINFO,
  2327. /**
  2328. * EVENT_INTERFACE_STATUS - Report interface status changes
  2329. *
  2330. * This optional event can be used to report changes in interface
  2331. * status (interface added/removed) using union
  2332. * wpa_event_data::interface_status. This can be used to trigger
  2333. * wpa_supplicant to stop and re-start processing for the interface,
  2334. * e.g., when a cardbus card is ejected/inserted.
  2335. */
  2336. EVENT_INTERFACE_STATUS,
  2337. /**
  2338. * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
  2339. *
  2340. * This event can be used to inform wpa_supplicant about candidates for
  2341. * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
  2342. * for scan request (ap_scan=2 mode), this event is required for
  2343. * pre-authentication. If wpa_supplicant is performing scan request
  2344. * (ap_scan=1), this event is optional since scan results can be used
  2345. * to add pre-authentication candidates. union
  2346. * wpa_event_data::pmkid_candidate is used to report the BSSID of the
  2347. * candidate and priority of the candidate, e.g., based on the signal
  2348. * strength, in order to try to pre-authenticate first with candidates
  2349. * that are most likely targets for re-association.
  2350. *
  2351. * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
  2352. * on the candidate list. In addition, it can be called for the current
  2353. * AP and APs that have existing PMKSA cache entries. wpa_supplicant
  2354. * will automatically skip pre-authentication in cases where a valid
  2355. * PMKSA exists. When more than one candidate exists, this event should
  2356. * be generated once for each candidate.
  2357. *
  2358. * Driver will be notified about successful pre-authentication with
  2359. * struct wpa_driver_ops::add_pmkid() calls.
  2360. */
  2361. EVENT_PMKID_CANDIDATE,
  2362. /**
  2363. * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
  2364. *
  2365. * This event can be used to inform wpa_supplicant about desire to set
  2366. * up secure direct link connection between two stations as defined in
  2367. * IEEE 802.11e with a new PeerKey mechanism that replaced the original
  2368. * STAKey negotiation. The caller will need to set peer address for the
  2369. * event.
  2370. */
  2371. EVENT_STKSTART,
  2372. /**
  2373. * EVENT_TDLS - Request TDLS operation
  2374. *
  2375. * This event can be used to request a TDLS operation to be performed.
  2376. */
  2377. EVENT_TDLS,
  2378. /**
  2379. * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
  2380. *
  2381. * The driver is expected to report the received FT IEs from
  2382. * FT authentication sequence from the AP. The FT IEs are included in
  2383. * the extra information in union wpa_event_data::ft_ies.
  2384. */
  2385. EVENT_FT_RESPONSE,
  2386. /**
  2387. * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
  2388. *
  2389. * The driver can use this event to inform wpa_supplicant about a STA
  2390. * in an IBSS with which protected frames could be exchanged. This
  2391. * event starts RSN authentication with the other STA to authenticate
  2392. * the STA and set up encryption keys with it.
  2393. */
  2394. EVENT_IBSS_RSN_START,
  2395. /**
  2396. * EVENT_AUTH - Authentication result
  2397. *
  2398. * This event should be called when authentication attempt has been
  2399. * completed. This is only used if the driver supports separate
  2400. * authentication step (struct wpa_driver_ops::authenticate).
  2401. * Information about authentication result is included in
  2402. * union wpa_event_data::auth.
  2403. */
  2404. EVENT_AUTH,
  2405. /**
  2406. * EVENT_DEAUTH - Authentication lost
  2407. *
  2408. * This event should be called when authentication is lost either due
  2409. * to receiving deauthenticate frame from the AP or when sending that
  2410. * frame to the current AP.
  2411. * In AP mode, union wpa_event_data::deauth_info is required.
  2412. */
  2413. EVENT_DEAUTH,
  2414. /**
  2415. * EVENT_ASSOC_REJECT - Association rejected
  2416. *
  2417. * This event should be called when (re)association attempt has been
  2418. * rejected by the AP. Information about the association response is
  2419. * included in union wpa_event_data::assoc_reject.
  2420. */
  2421. EVENT_ASSOC_REJECT,
  2422. /**
  2423. * EVENT_AUTH_TIMED_OUT - Authentication timed out
  2424. */
  2425. EVENT_AUTH_TIMED_OUT,
  2426. /**
  2427. * EVENT_ASSOC_TIMED_OUT - Association timed out
  2428. */
  2429. EVENT_ASSOC_TIMED_OUT,
  2430. /**
  2431. * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
  2432. */
  2433. EVENT_FT_RRB_RX,
  2434. /**
  2435. * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
  2436. */
  2437. EVENT_WPS_BUTTON_PUSHED,
  2438. /**
  2439. * EVENT_TX_STATUS - Report TX status
  2440. */
  2441. EVENT_TX_STATUS,
  2442. /**
  2443. * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
  2444. */
  2445. EVENT_RX_FROM_UNKNOWN,
  2446. /**
  2447. * EVENT_RX_MGMT - Report RX of a management frame
  2448. */
  2449. EVENT_RX_MGMT,
  2450. /**
  2451. * EVENT_RX_ACTION - Action frame received
  2452. *
  2453. * This event is used to indicate when an Action frame has been
  2454. * received. Information about the received frame is included in
  2455. * union wpa_event_data::rx_action.
  2456. */
  2457. EVENT_RX_ACTION,
  2458. /**
  2459. * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
  2460. *
  2461. * This event is used to indicate when the driver has started the
  2462. * requested remain-on-channel duration. Information about the
  2463. * operation is included in union wpa_event_data::remain_on_channel.
  2464. */
  2465. EVENT_REMAIN_ON_CHANNEL,
  2466. /**
  2467. * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
  2468. *
  2469. * This event is used to indicate when the driver has completed
  2470. * remain-on-channel duration, i.e., may noot be available on the
  2471. * requested channel anymore. Information about the
  2472. * operation is included in union wpa_event_data::remain_on_channel.
  2473. */
  2474. EVENT_CANCEL_REMAIN_ON_CHANNEL,
  2475. /**
  2476. * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
  2477. *
  2478. * This event is used only by driver_test.c and userspace MLME.
  2479. */
  2480. EVENT_MLME_RX,
  2481. /**
  2482. * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
  2483. *
  2484. * This event is used to indicate when a Probe Request frame has been
  2485. * received. Information about the received frame is included in
  2486. * union wpa_event_data::rx_probe_req. The driver is required to report
  2487. * these events only after successfully completed probe_req_report()
  2488. * commands to request the events (i.e., report parameter is non-zero)
  2489. * in station mode. In AP mode, Probe Request frames should always be
  2490. * reported.
  2491. */
  2492. EVENT_RX_PROBE_REQ,
  2493. /**
  2494. * EVENT_NEW_STA - New wired device noticed
  2495. *
  2496. * This event is used to indicate that a new device has been detected
  2497. * in a network that does not use association-like functionality (i.e.,
  2498. * mainly wired Ethernet). This can be used to start EAPOL
  2499. * authenticator when receiving a frame from a device. The address of
  2500. * the device is included in union wpa_event_data::new_sta.
  2501. */
  2502. EVENT_NEW_STA,
  2503. /**
  2504. * EVENT_EAPOL_RX - Report received EAPOL frame
  2505. *
  2506. * When in AP mode with hostapd, this event is required to be used to
  2507. * deliver the receive EAPOL frames from the driver. With
  2508. * %wpa_supplicant, this event is used only if the send_eapol() handler
  2509. * is used to override the use of l2_packet for EAPOL frame TX.
  2510. */
  2511. EVENT_EAPOL_RX,
  2512. /**
  2513. * EVENT_SIGNAL_CHANGE - Indicate change in signal strength
  2514. *
  2515. * This event is used to indicate changes in the signal strength
  2516. * observed in frames received from the current AP if signal strength
  2517. * monitoring has been enabled with signal_monitor().
  2518. */
  2519. EVENT_SIGNAL_CHANGE,
  2520. /**
  2521. * EVENT_INTERFACE_ENABLED - Notify that interface was enabled
  2522. *
  2523. * This event is used to indicate that the interface was enabled after
  2524. * having been previously disabled, e.g., due to rfkill.
  2525. */
  2526. EVENT_INTERFACE_ENABLED,
  2527. /**
  2528. * EVENT_INTERFACE_DISABLED - Notify that interface was disabled
  2529. *
  2530. * This event is used to indicate that the interface was disabled,
  2531. * e.g., due to rfkill.
  2532. */
  2533. EVENT_INTERFACE_DISABLED,
  2534. /**
  2535. * EVENT_CHANNEL_LIST_CHANGED - Channel list changed
  2536. *
  2537. * This event is used to indicate that the channel list has changed,
  2538. * e.g., because of a regulatory domain change triggered by scan
  2539. * results including an AP advertising a country code.
  2540. */
  2541. EVENT_CHANNEL_LIST_CHANGED,
  2542. /**
  2543. * EVENT_INTERFACE_UNAVAILABLE - Notify that interface is unavailable
  2544. *
  2545. * This event is used to indicate that the driver cannot maintain this
  2546. * interface in its operation mode anymore. The most likely use for
  2547. * this is to indicate that AP mode operation is not available due to
  2548. * operating channel would need to be changed to a DFS channel when
  2549. * the driver does not support radar detection and another virtual
  2550. * interfaces caused the operating channel to change. Other similar
  2551. * resource conflicts could also trigger this for station mode
  2552. * interfaces.
  2553. */
  2554. EVENT_INTERFACE_UNAVAILABLE,
  2555. /**
  2556. * EVENT_BEST_CHANNEL
  2557. *
  2558. * Driver generates this event whenever it detects a better channel
  2559. * (e.g., based on RSSI or channel use). This information can be used
  2560. * to improve channel selection for a new AP/P2P group.
  2561. */
  2562. EVENT_BEST_CHANNEL,
  2563. /**
  2564. * EVENT_UNPROT_DEAUTH - Unprotected Deauthentication frame received
  2565. *
  2566. * This event should be called when a Deauthentication frame is dropped
  2567. * due to it not being protected (MFP/IEEE 802.11w).
  2568. * union wpa_event_data::unprot_deauth is required to provide more
  2569. * details of the frame.
  2570. */
  2571. EVENT_UNPROT_DEAUTH,
  2572. /**
  2573. * EVENT_UNPROT_DISASSOC - Unprotected Disassociation frame received
  2574. *
  2575. * This event should be called when a Disassociation frame is dropped
  2576. * due to it not being protected (MFP/IEEE 802.11w).
  2577. * union wpa_event_data::unprot_disassoc is required to provide more
  2578. * details of the frame.
  2579. */
  2580. EVENT_UNPROT_DISASSOC,
  2581. /**
  2582. * EVENT_STATION_LOW_ACK
  2583. *
  2584. * Driver generates this event whenever it detected that a particular
  2585. * station was lost. Detection can be through massive transmission
  2586. * failures for example.
  2587. */
  2588. EVENT_STATION_LOW_ACK,
  2589. /**
  2590. * EVENT_P2P_DEV_FOUND - Report a discovered P2P device
  2591. *
  2592. * This event is used only if the driver implements P2P management
  2593. * internally. Event data is stored in
  2594. * union wpa_event_data::p2p_dev_found.
  2595. */
  2596. EVENT_P2P_DEV_FOUND,
  2597. /**
  2598. * EVENT_P2P_GO_NEG_REQ_RX - Report reception of GO Negotiation Request
  2599. *
  2600. * This event is used only if the driver implements P2P management
  2601. * internally. Event data is stored in
  2602. * union wpa_event_data::p2p_go_neg_req_rx.
  2603. */
  2604. EVENT_P2P_GO_NEG_REQ_RX,
  2605. /**
  2606. * EVENT_P2P_GO_NEG_COMPLETED - Report completion of GO Negotiation
  2607. *
  2608. * This event is used only if the driver implements P2P management
  2609. * internally. Event data is stored in
  2610. * union wpa_event_data::p2p_go_neg_completed.
  2611. */
  2612. EVENT_P2P_GO_NEG_COMPLETED,
  2613. EVENT_P2P_PROV_DISC_REQUEST,
  2614. EVENT_P2P_PROV_DISC_RESPONSE,
  2615. EVENT_P2P_SD_REQUEST,
  2616. EVENT_P2P_SD_RESPONSE,
  2617. /**
  2618. * EVENT_IBSS_PEER_LOST - IBSS peer not reachable anymore
  2619. */
  2620. EVENT_IBSS_PEER_LOST,
  2621. /**
  2622. * EVENT_DRIVER_GTK_REKEY - Device/driver did GTK rekey
  2623. *
  2624. * This event carries the new replay counter to notify wpa_supplicant
  2625. * of the current EAPOL-Key Replay Counter in case the driver/firmware
  2626. * completed Group Key Handshake while the host (including
  2627. * wpa_supplicant was sleeping).
  2628. */
  2629. EVENT_DRIVER_GTK_REKEY,
  2630. /**
  2631. * EVENT_SCHED_SCAN_STOPPED - Scheduled scan was stopped
  2632. */
  2633. EVENT_SCHED_SCAN_STOPPED
  2634. };
  2635. /**
  2636. * union wpa_event_data - Additional data for wpa_supplicant_event() calls
  2637. */
  2638. union wpa_event_data {
  2639. /**
  2640. * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
  2641. *
  2642. * This structure is optional for EVENT_ASSOC calls and required for
  2643. * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
  2644. * driver interface does not need to generate separate EVENT_ASSOCINFO
  2645. * calls.
  2646. */
  2647. struct assoc_info {
  2648. /**
  2649. * reassoc - Flag to indicate association or reassociation
  2650. */
  2651. int reassoc;
  2652. /**
  2653. * req_ies - (Re)Association Request IEs
  2654. *
  2655. * If the driver generates WPA/RSN IE, this event data must be
  2656. * returned for WPA handshake to have needed information. If
  2657. * wpa_supplicant-generated WPA/RSN IE is used, this
  2658. * information event is optional.
  2659. *
  2660. * This should start with the first IE (fixed fields before IEs
  2661. * are not included).
  2662. */
  2663. const u8 *req_ies;
  2664. /**
  2665. * req_ies_len - Length of req_ies in bytes
  2666. */
  2667. size_t req_ies_len;
  2668. /**
  2669. * resp_ies - (Re)Association Response IEs
  2670. *
  2671. * Optional association data from the driver. This data is not
  2672. * required WPA, but may be useful for some protocols and as
  2673. * such, should be reported if this is available to the driver
  2674. * interface.
  2675. *
  2676. * This should start with the first IE (fixed fields before IEs
  2677. * are not included).
  2678. */
  2679. const u8 *resp_ies;
  2680. /**
  2681. * resp_ies_len - Length of resp_ies in bytes
  2682. */
  2683. size_t resp_ies_len;
  2684. /**
  2685. * beacon_ies - Beacon or Probe Response IEs
  2686. *
  2687. * Optional Beacon/ProbeResp data: IEs included in Beacon or
  2688. * Probe Response frames from the current AP (i.e., the one
  2689. * that the client just associated with). This information is
  2690. * used to update WPA/RSN IE for the AP. If this field is not
  2691. * set, the results from previous scan will be used. If no
  2692. * data for the new AP is found, scan results will be requested
  2693. * again (without scan request). At this point, the driver is
  2694. * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
  2695. * used).
  2696. *
  2697. * This should start with the first IE (fixed fields before IEs
  2698. * are not included).
  2699. */
  2700. const u8 *beacon_ies;
  2701. /**
  2702. * beacon_ies_len - Length of beacon_ies */
  2703. size_t beacon_ies_len;
  2704. /**
  2705. * freq - Frequency of the operational channel in MHz
  2706. */
  2707. unsigned int freq;
  2708. /**
  2709. * addr - Station address (for AP mode)
  2710. */
  2711. const u8 *addr;
  2712. } assoc_info;
  2713. /**
  2714. * struct disassoc_info - Data for EVENT_DISASSOC events
  2715. */
  2716. struct disassoc_info {
  2717. /**
  2718. * addr - Station address (for AP mode)
  2719. */
  2720. const u8 *addr;
  2721. /**
  2722. * reason_code - Reason Code (host byte order) used in
  2723. * Deauthentication frame
  2724. */
  2725. u16 reason_code;
  2726. /**
  2727. * ie - Optional IE(s) in Disassociation frame
  2728. */
  2729. const u8 *ie;
  2730. /**
  2731. * ie_len - Length of ie buffer in octets
  2732. */
  2733. size_t ie_len;
  2734. } disassoc_info;
  2735. /**
  2736. * struct deauth_info - Data for EVENT_DEAUTH events
  2737. */
  2738. struct deauth_info {
  2739. /**
  2740. * addr - Station address (for AP mode)
  2741. */
  2742. const u8 *addr;
  2743. /**
  2744. * reason_code - Reason Code (host byte order) used in
  2745. * Deauthentication frame
  2746. */
  2747. u16 reason_code;
  2748. /**
  2749. * ie - Optional IE(s) in Deauthentication frame
  2750. */
  2751. const u8 *ie;
  2752. /**
  2753. * ie_len - Length of ie buffer in octets
  2754. */
  2755. size_t ie_len;
  2756. } deauth_info;
  2757. /**
  2758. * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
  2759. */
  2760. struct michael_mic_failure {
  2761. int unicast;
  2762. const u8 *src;
  2763. } michael_mic_failure;
  2764. /**
  2765. * struct interface_status - Data for EVENT_INTERFACE_STATUS
  2766. */
  2767. struct interface_status {
  2768. char ifname[100];
  2769. enum {
  2770. EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
  2771. } ievent;
  2772. } interface_status;
  2773. /**
  2774. * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
  2775. */
  2776. struct pmkid_candidate {
  2777. /** BSSID of the PMKID candidate */
  2778. u8 bssid[ETH_ALEN];
  2779. /** Smaller the index, higher the priority */
  2780. int index;
  2781. /** Whether RSN IE includes pre-authenticate flag */
  2782. int preauth;
  2783. } pmkid_candidate;
  2784. /**
  2785. * struct stkstart - Data for EVENT_STKSTART
  2786. */
  2787. struct stkstart {
  2788. u8 peer[ETH_ALEN];
  2789. } stkstart;
  2790. /**
  2791. * struct tdls - Data for EVENT_TDLS
  2792. */
  2793. struct tdls {
  2794. u8 peer[ETH_ALEN];
  2795. enum {
  2796. TDLS_REQUEST_SETUP,
  2797. TDLS_REQUEST_TEARDOWN
  2798. } oper;
  2799. u16 reason_code; /* for teardown */
  2800. } tdls;
  2801. /**
  2802. * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
  2803. *
  2804. * During FT (IEEE 802.11r) authentication sequence, the driver is
  2805. * expected to use this event to report received FT IEs (MDIE, FTIE,
  2806. * RSN IE, TIE, possible resource request) to the supplicant. The FT
  2807. * IEs for the next message will be delivered through the
  2808. * struct wpa_driver_ops::update_ft_ies() callback.
  2809. */
  2810. struct ft_ies {
  2811. const u8 *ies;
  2812. size_t ies_len;
  2813. int ft_action;
  2814. u8 target_ap[ETH_ALEN];
  2815. /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
  2816. const u8 *ric_ies;
  2817. /** Length of ric_ies buffer in octets */
  2818. size_t ric_ies_len;
  2819. } ft_ies;
  2820. /**
  2821. * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
  2822. */
  2823. struct ibss_rsn_start {
  2824. u8 peer[ETH_ALEN];
  2825. } ibss_rsn_start;
  2826. /**
  2827. * struct auth_info - Data for EVENT_AUTH events
  2828. */
  2829. struct auth_info {
  2830. u8 peer[ETH_ALEN];
  2831. u8 bssid[ETH_ALEN];
  2832. u16 auth_type;
  2833. u16 auth_transaction;
  2834. u16 status_code;
  2835. const u8 *ies;
  2836. size_t ies_len;
  2837. } auth;
  2838. /**
  2839. * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
  2840. */
  2841. struct assoc_reject {
  2842. /**
  2843. * bssid - BSSID of the AP that rejected association
  2844. */
  2845. const u8 *bssid;
  2846. /**
  2847. * resp_ies - (Re)Association Response IEs
  2848. *
  2849. * Optional association data from the driver. This data is not
  2850. * required WPA, but may be useful for some protocols and as
  2851. * such, should be reported if this is available to the driver
  2852. * interface.
  2853. *
  2854. * This should start with the first IE (fixed fields before IEs
  2855. * are not included).
  2856. */
  2857. const u8 *resp_ies;
  2858. /**
  2859. * resp_ies_len - Length of resp_ies in bytes
  2860. */
  2861. size_t resp_ies_len;
  2862. /**
  2863. * status_code - Status Code from (Re)association Response
  2864. */
  2865. u16 status_code;
  2866. } assoc_reject;
  2867. struct timeout_event {
  2868. u8 addr[ETH_ALEN];
  2869. } timeout_event;
  2870. /**
  2871. * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
  2872. */
  2873. struct ft_rrb_rx {
  2874. const u8 *src;
  2875. const u8 *data;
  2876. size_t data_len;
  2877. } ft_rrb_rx;
  2878. /**
  2879. * struct tx_status - Data for EVENT_TX_STATUS events
  2880. */
  2881. struct tx_status {
  2882. u16 type;
  2883. u16 stype;
  2884. const u8 *dst;
  2885. const u8 *data;
  2886. size_t data_len;
  2887. int ack;
  2888. } tx_status;
  2889. /**
  2890. * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
  2891. */
  2892. struct rx_from_unknown {
  2893. const u8 *frame;
  2894. size_t len;
  2895. } rx_from_unknown;
  2896. /**
  2897. * struct rx_mgmt - Data for EVENT_RX_MGMT events
  2898. */
  2899. struct rx_mgmt {
  2900. const u8 *frame;
  2901. size_t frame_len;
  2902. u32 datarate;
  2903. u32 ssi_signal;
  2904. } rx_mgmt;
  2905. /**
  2906. * struct rx_action - Data for EVENT_RX_ACTION events
  2907. */
  2908. struct rx_action {
  2909. /**
  2910. * da - Destination address of the received Action frame
  2911. */
  2912. const u8 *da;
  2913. /**
  2914. * sa - Source address of the received Action frame
  2915. */
  2916. const u8 *sa;
  2917. /**
  2918. * bssid - Address 3 of the received Action frame
  2919. */
  2920. const u8 *bssid;
  2921. /**
  2922. * category - Action frame category
  2923. */
  2924. u8 category;
  2925. /**
  2926. * data - Action frame body after category field
  2927. */
  2928. const u8 *data;
  2929. /**
  2930. * len - Length of data in octets
  2931. */
  2932. size_t len;
  2933. /**
  2934. * freq - Frequency (in MHz) on which the frame was received
  2935. */
  2936. int freq;
  2937. } rx_action;
  2938. /**
  2939. * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
  2940. *
  2941. * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
  2942. */
  2943. struct remain_on_channel {
  2944. /**
  2945. * freq - Channel frequency in MHz
  2946. */
  2947. unsigned int freq;
  2948. /**
  2949. * duration - Duration to remain on the channel in milliseconds
  2950. */
  2951. unsigned int duration;
  2952. } remain_on_channel;
  2953. /**
  2954. * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
  2955. * @aborted: Whether the scan was aborted
  2956. * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
  2957. * @num_freqs: Number of entries in freqs array
  2958. * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
  2959. * SSID)
  2960. * @num_ssids: Number of entries in ssids array
  2961. */
  2962. struct scan_info {
  2963. int aborted;
  2964. const int *freqs;
  2965. size_t num_freqs;
  2966. struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
  2967. size_t num_ssids;
  2968. } scan_info;
  2969. /**
  2970. * struct mlme_rx - Data for EVENT_MLME_RX events
  2971. */
  2972. struct mlme_rx {
  2973. const u8 *buf;
  2974. size_t len;
  2975. int freq;
  2976. int channel;
  2977. int ssi;
  2978. } mlme_rx;
  2979. /**
  2980. * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
  2981. */
  2982. struct rx_probe_req {
  2983. /**
  2984. * sa - Source address of the received Probe Request frame
  2985. */
  2986. const u8 *sa;
  2987. /**
  2988. * da - Destination address of the received Probe Request frame
  2989. * or %NULL if not available
  2990. */
  2991. const u8 *da;
  2992. /**
  2993. * bssid - BSSID of the received Probe Request frame or %NULL
  2994. * if not available
  2995. */
  2996. const u8 *bssid;
  2997. /**
  2998. * ie - IEs from the Probe Request body
  2999. */
  3000. const u8 *ie;
  3001. /**
  3002. * ie_len - Length of ie buffer in octets
  3003. */
  3004. size_t ie_len;
  3005. } rx_probe_req;
  3006. /**
  3007. * struct new_sta - Data for EVENT_NEW_STA events
  3008. */
  3009. struct new_sta {
  3010. const u8 *addr;
  3011. } new_sta;
  3012. /**
  3013. * struct eapol_rx - Data for EVENT_EAPOL_RX events
  3014. */
  3015. struct eapol_rx {
  3016. const u8 *src;
  3017. const u8 *data;
  3018. size_t data_len;
  3019. } eapol_rx;
  3020. /**
  3021. * signal_change - Data for EVENT_SIGNAL_CHANGE events
  3022. */
  3023. struct wpa_signal_info signal_change;
  3024. /**
  3025. * struct best_channel - Data for EVENT_BEST_CHANNEL events
  3026. * @freq_24: Best 2.4 GHz band channel frequency in MHz
  3027. * @freq_5: Best 5 GHz band channel frequency in MHz
  3028. * @freq_overall: Best channel frequency in MHz
  3029. *
  3030. * 0 can be used to indicate no preference in either band.
  3031. */
  3032. struct best_channel {
  3033. int freq_24;
  3034. int freq_5;
  3035. int freq_overall;
  3036. } best_chan;
  3037. struct unprot_deauth {
  3038. const u8 *sa;
  3039. const u8 *da;
  3040. u16 reason_code;
  3041. } unprot_deauth;
  3042. struct unprot_disassoc {
  3043. const u8 *sa;
  3044. const u8 *da;
  3045. u16 reason_code;
  3046. } unprot_disassoc;
  3047. /**
  3048. * struct low_ack - Data for EVENT_STATION_LOW_ACK events
  3049. * @addr: station address
  3050. */
  3051. struct low_ack {
  3052. u8 addr[ETH_ALEN];
  3053. } low_ack;
  3054. /**
  3055. * struct p2p_dev_found - Data for EVENT_P2P_DEV_FOUND
  3056. */
  3057. struct p2p_dev_found {
  3058. const u8 *addr;
  3059. const u8 *dev_addr;
  3060. const u8 *pri_dev_type;
  3061. const char *dev_name;
  3062. u16 config_methods;
  3063. u8 dev_capab;
  3064. u8 group_capab;
  3065. } p2p_dev_found;
  3066. /**
  3067. * struct p2p_go_neg_req_rx - Data for EVENT_P2P_GO_NEG_REQ_RX
  3068. */
  3069. struct p2p_go_neg_req_rx {
  3070. const u8 *src;
  3071. u16 dev_passwd_id;
  3072. } p2p_go_neg_req_rx;
  3073. /**
  3074. * struct p2p_go_neg_completed - Data for EVENT_P2P_GO_NEG_COMPLETED
  3075. */
  3076. struct p2p_go_neg_completed {
  3077. struct p2p_go_neg_results *res;
  3078. } p2p_go_neg_completed;
  3079. struct p2p_prov_disc_req {
  3080. const u8 *peer;
  3081. u16 config_methods;
  3082. const u8 *dev_addr;
  3083. const u8 *pri_dev_type;
  3084. const char *dev_name;
  3085. u16 supp_config_methods;
  3086. u8 dev_capab;
  3087. u8 group_capab;
  3088. } p2p_prov_disc_req;
  3089. struct p2p_prov_disc_resp {
  3090. const u8 *peer;
  3091. u16 config_methods;
  3092. } p2p_prov_disc_resp;
  3093. struct p2p_sd_req {
  3094. int freq;
  3095. const u8 *sa;
  3096. u8 dialog_token;
  3097. u16 update_indic;
  3098. const u8 *tlvs;
  3099. size_t tlvs_len;
  3100. } p2p_sd_req;
  3101. struct p2p_sd_resp {
  3102. const u8 *sa;
  3103. u16 update_indic;
  3104. const u8 *tlvs;
  3105. size_t tlvs_len;
  3106. } p2p_sd_resp;
  3107. /**
  3108. * struct ibss_peer_lost - Data for EVENT_IBSS_PEER_LOST
  3109. */
  3110. struct ibss_peer_lost {
  3111. u8 peer[ETH_ALEN];
  3112. } ibss_peer_lost;
  3113. /**
  3114. * struct driver_gtk_rekey - Data for EVENT_DRIVER_GTK_REKEY
  3115. */
  3116. struct driver_gtk_rekey {
  3117. const u8 *bssid;
  3118. const u8 *replay_ctr;
  3119. } driver_gtk_rekey;
  3120. };
  3121. /**
  3122. * wpa_supplicant_event - Report a driver event for wpa_supplicant
  3123. * @ctx: Context pointer (wpa_s); this is the ctx variable registered
  3124. * with struct wpa_driver_ops::init()
  3125. * @event: event type (defined above)
  3126. * @data: possible extra data for the event
  3127. *
  3128. * Driver wrapper code should call this function whenever an event is received
  3129. * from the driver.
  3130. */
  3131. void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
  3132. union wpa_event_data *data);
  3133. /*
  3134. * The following inline functions are provided for convenience to simplify
  3135. * event indication for some of the common events.
  3136. */
  3137. static inline void drv_event_assoc(void *ctx, const u8 *addr, const u8 *ie,
  3138. size_t ielen, int reassoc)
  3139. {
  3140. union wpa_event_data event;
  3141. os_memset(&event, 0, sizeof(event));
  3142. event.assoc_info.reassoc = reassoc;
  3143. event.assoc_info.req_ies = ie;
  3144. event.assoc_info.req_ies_len = ielen;
  3145. event.assoc_info.addr = addr;
  3146. wpa_supplicant_event(ctx, EVENT_ASSOC, &event);
  3147. }
  3148. static inline void drv_event_disassoc(void *ctx, const u8 *addr)
  3149. {
  3150. union wpa_event_data event;
  3151. os_memset(&event, 0, sizeof(event));
  3152. event.disassoc_info.addr = addr;
  3153. wpa_supplicant_event(ctx, EVENT_DISASSOC, &event);
  3154. }
  3155. static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
  3156. size_t data_len)
  3157. {
  3158. union wpa_event_data event;
  3159. os_memset(&event, 0, sizeof(event));
  3160. event.eapol_rx.src = src;
  3161. event.eapol_rx.data = data;
  3162. event.eapol_rx.data_len = data_len;
  3163. wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
  3164. }
  3165. #endif /* DRIVER_H */