driver.h 64 KB

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