driver.h 52 KB

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