driver.h 53 KB

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