driver_i.h 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. /*
  2. * wpa_supplicant - Internal driver interface wrappers
  3. * Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef DRIVER_I_H
  9. #define DRIVER_I_H
  10. #include "drivers/driver.h"
  11. /* driver_ops */
  12. static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
  13. const char *ifname)
  14. {
  15. if (wpa_s->driver->init2)
  16. return wpa_s->driver->init2(wpa_s, ifname,
  17. wpa_s->global_drv_priv);
  18. if (wpa_s->driver->init) {
  19. return wpa_s->driver->init(wpa_s, ifname);
  20. }
  21. return NULL;
  22. }
  23. static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
  24. {
  25. if (wpa_s->driver->deinit)
  26. wpa_s->driver->deinit(wpa_s->drv_priv);
  27. }
  28. static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
  29. const char *param)
  30. {
  31. if (wpa_s->driver->set_param)
  32. return wpa_s->driver->set_param(wpa_s->drv_priv, param);
  33. return 0;
  34. }
  35. static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
  36. int enabled)
  37. {
  38. if (wpa_s->driver->set_countermeasures) {
  39. return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
  40. enabled);
  41. }
  42. return -1;
  43. }
  44. static inline int wpa_drv_authenticate(struct wpa_supplicant *wpa_s,
  45. struct wpa_driver_auth_params *params)
  46. {
  47. if (wpa_s->driver->authenticate)
  48. return wpa_s->driver->authenticate(wpa_s->drv_priv, params);
  49. return -1;
  50. }
  51. static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
  52. struct wpa_driver_associate_params *params)
  53. {
  54. if (wpa_s->driver->associate) {
  55. return wpa_s->driver->associate(wpa_s->drv_priv, params);
  56. }
  57. return -1;
  58. }
  59. static inline int wpa_drv_init_mesh(struct wpa_supplicant *wpa_s)
  60. {
  61. if (wpa_s->driver->init_mesh)
  62. return wpa_s->driver->init_mesh(wpa_s->drv_priv);
  63. return -1;
  64. }
  65. static inline int wpa_drv_join_mesh(struct wpa_supplicant *wpa_s,
  66. struct wpa_driver_mesh_join_params *params)
  67. {
  68. if (wpa_s->driver->join_mesh)
  69. return wpa_s->driver->join_mesh(wpa_s->drv_priv, params);
  70. return -1;
  71. }
  72. static inline int wpa_drv_leave_mesh(struct wpa_supplicant *wpa_s)
  73. {
  74. if (wpa_s->driver->leave_mesh)
  75. return wpa_s->driver->leave_mesh(wpa_s->drv_priv);
  76. return -1;
  77. }
  78. static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s,
  79. struct wpa_driver_scan_params *params)
  80. {
  81. #ifdef CONFIG_TESTING_OPTIONS
  82. if (wpa_s->test_failure == WPAS_TEST_FAILURE_SCAN_TRIGGER)
  83. return -EBUSY;
  84. #endif /* CONFIG_TESTING_OPTIONS */
  85. if (wpa_s->driver->scan2)
  86. return wpa_s->driver->scan2(wpa_s->drv_priv, params);
  87. return -1;
  88. }
  89. static inline int wpa_drv_sched_scan(struct wpa_supplicant *wpa_s,
  90. struct wpa_driver_scan_params *params)
  91. {
  92. if (wpa_s->driver->sched_scan)
  93. return wpa_s->driver->sched_scan(wpa_s->drv_priv, params);
  94. return -1;
  95. }
  96. static inline int wpa_drv_stop_sched_scan(struct wpa_supplicant *wpa_s)
  97. {
  98. if (wpa_s->driver->stop_sched_scan)
  99. return wpa_s->driver->stop_sched_scan(wpa_s->drv_priv);
  100. return -1;
  101. }
  102. static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
  103. struct wpa_supplicant *wpa_s)
  104. {
  105. if (wpa_s->driver->get_scan_results2)
  106. return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
  107. return NULL;
  108. }
  109. static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
  110. {
  111. if (wpa_s->driver->get_bssid) {
  112. return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
  113. }
  114. return -1;
  115. }
  116. static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
  117. {
  118. if (wpa_s->driver->get_ssid) {
  119. return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
  120. }
  121. return -1;
  122. }
  123. static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s,
  124. enum wpa_alg alg, const u8 *addr,
  125. int key_idx, int set_tx,
  126. const u8 *seq, size_t seq_len,
  127. const u8 *key, size_t key_len)
  128. {
  129. if (alg != WPA_ALG_NONE) {
  130. if (key_idx >= 0 && key_idx <= 6)
  131. wpa_s->keys_cleared &= ~BIT(key_idx);
  132. else
  133. wpa_s->keys_cleared = 0;
  134. }
  135. if (wpa_s->driver->set_key) {
  136. return wpa_s->driver->set_key(wpa_s->ifname, wpa_s->drv_priv,
  137. alg, addr, key_idx, set_tx,
  138. seq, seq_len, key, key_len);
  139. }
  140. return -1;
  141. }
  142. static inline int wpa_drv_get_seqnum(struct wpa_supplicant *wpa_s,
  143. const u8 *addr, int idx, u8 *seq)
  144. {
  145. if (wpa_s->driver->get_seqnum)
  146. return wpa_s->driver->get_seqnum(wpa_s->ifname, wpa_s->drv_priv,
  147. addr, idx, seq);
  148. return -1;
  149. }
  150. static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
  151. const u8 *addr, int reason_code)
  152. {
  153. if (wpa_s->driver->sta_deauth) {
  154. return wpa_s->driver->sta_deauth(wpa_s->drv_priv,
  155. wpa_s->own_addr, addr,
  156. reason_code);
  157. }
  158. return -1;
  159. }
  160. static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
  161. const u8 *addr, int reason_code)
  162. {
  163. if (wpa_s->driver->deauthenticate) {
  164. return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
  165. reason_code);
  166. }
  167. return -1;
  168. }
  169. static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
  170. struct wpa_pmkid_params *params)
  171. {
  172. if (wpa_s->driver->add_pmkid) {
  173. return wpa_s->driver->add_pmkid(wpa_s->drv_priv, params);
  174. }
  175. return -1;
  176. }
  177. static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
  178. struct wpa_pmkid_params *params)
  179. {
  180. if (wpa_s->driver->remove_pmkid) {
  181. return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, params);
  182. }
  183. return -1;
  184. }
  185. static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
  186. {
  187. if (wpa_s->driver->flush_pmkid) {
  188. return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
  189. }
  190. return -1;
  191. }
  192. static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
  193. struct wpa_driver_capa *capa)
  194. {
  195. if (wpa_s->driver->get_capa) {
  196. return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
  197. }
  198. return -1;
  199. }
  200. static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
  201. {
  202. if (wpa_s->driver->poll) {
  203. wpa_s->driver->poll(wpa_s->drv_priv);
  204. }
  205. }
  206. static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
  207. {
  208. if (wpa_s->driver->get_ifname) {
  209. return wpa_s->driver->get_ifname(wpa_s->drv_priv);
  210. }
  211. return NULL;
  212. }
  213. static inline const char *
  214. wpa_driver_get_radio_name(struct wpa_supplicant *wpa_s)
  215. {
  216. if (wpa_s->driver->get_radio_name)
  217. return wpa_s->driver->get_radio_name(wpa_s->drv_priv);
  218. return NULL;
  219. }
  220. static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
  221. {
  222. if (wpa_s->driver->get_mac_addr) {
  223. return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
  224. }
  225. return NULL;
  226. }
  227. static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
  228. int state)
  229. {
  230. if (wpa_s->driver->set_operstate)
  231. return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
  232. return 0;
  233. }
  234. static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
  235. const u8 *addr, int protect_type,
  236. int key_type)
  237. {
  238. if (wpa_s->driver->mlme_setprotection)
  239. return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
  240. protect_type,
  241. key_type);
  242. return 0;
  243. }
  244. static inline struct hostapd_hw_modes *
  245. wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
  246. u16 *flags, u8 *dfs_domain)
  247. {
  248. if (wpa_s->driver->get_hw_feature_data)
  249. return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
  250. num_modes, flags,
  251. dfs_domain);
  252. return NULL;
  253. }
  254. static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
  255. const char *alpha2)
  256. {
  257. if (wpa_s->driver->set_country)
  258. return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
  259. return 0;
  260. }
  261. static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
  262. const u8 *data, size_t data_len, int noack,
  263. unsigned int freq)
  264. {
  265. if (wpa_s->driver->send_mlme)
  266. return wpa_s->driver->send_mlme(wpa_s->drv_priv,
  267. data, data_len, noack,
  268. freq, NULL, 0);
  269. return -1;
  270. }
  271. static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
  272. const u8 *md,
  273. const u8 *ies, size_t ies_len)
  274. {
  275. if (wpa_s->driver->update_ft_ies)
  276. return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
  277. ies, ies_len);
  278. return -1;
  279. }
  280. static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
  281. struct wpa_driver_ap_params *params)
  282. {
  283. if (wpa_s->driver->set_ap)
  284. return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
  285. return -1;
  286. }
  287. static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s,
  288. struct hostapd_sta_add_params *params)
  289. {
  290. if (wpa_s->driver->sta_add)
  291. return wpa_s->driver->sta_add(wpa_s->drv_priv, params);
  292. return -1;
  293. }
  294. static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s,
  295. const u8 *addr)
  296. {
  297. if (wpa_s->driver->sta_remove)
  298. return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr);
  299. return -1;
  300. }
  301. static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
  302. const u8 *addr, const u8 *data,
  303. size_t data_len, int encrypt,
  304. const u8 *own_addr, u32 flags)
  305. {
  306. if (wpa_s->driver->hapd_send_eapol)
  307. return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
  308. data, data_len, encrypt,
  309. own_addr, flags);
  310. return -1;
  311. }
  312. static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s,
  313. const u8 *addr, int total_flags,
  314. int flags_or, int flags_and)
  315. {
  316. if (wpa_s->driver->sta_set_flags)
  317. return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr,
  318. total_flags, flags_or,
  319. flags_and);
  320. return -1;
  321. }
  322. static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
  323. int authorized)
  324. {
  325. if (wpa_s->driver->set_supp_port) {
  326. return wpa_s->driver->set_supp_port(wpa_s->drv_priv,
  327. authorized);
  328. }
  329. return 0;
  330. }
  331. static inline int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
  332. unsigned int freq,
  333. unsigned int wait,
  334. const u8 *dst, const u8 *src,
  335. const u8 *bssid,
  336. const u8 *data, size_t data_len,
  337. int no_cck)
  338. {
  339. if (wpa_s->driver->send_action)
  340. return wpa_s->driver->send_action(wpa_s->drv_priv, freq,
  341. wait, dst, src, bssid,
  342. data, data_len, no_cck);
  343. return -1;
  344. }
  345. static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s)
  346. {
  347. if (wpa_s->driver->send_action_cancel_wait)
  348. wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv);
  349. }
  350. static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s,
  351. struct hostapd_freq_params *freq)
  352. {
  353. if (wpa_s->driver->set_freq)
  354. return wpa_s->driver->set_freq(wpa_s->drv_priv, freq);
  355. return -1;
  356. }
  357. static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
  358. enum wpa_driver_if_type type,
  359. const char *ifname, const u8 *addr,
  360. void *bss_ctx, char *force_ifname,
  361. u8 *if_addr, const char *bridge)
  362. {
  363. if (wpa_s->driver->if_add)
  364. return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
  365. addr, bss_ctx, NULL, force_ifname,
  366. if_addr, bridge, 0, 0);
  367. return -1;
  368. }
  369. static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s,
  370. enum wpa_driver_if_type type,
  371. const char *ifname)
  372. {
  373. if (wpa_s->driver->if_remove)
  374. return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname);
  375. return -1;
  376. }
  377. static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s,
  378. unsigned int freq,
  379. unsigned int duration)
  380. {
  381. if (wpa_s->driver->remain_on_channel)
  382. return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq,
  383. duration);
  384. return -1;
  385. }
  386. static inline int wpa_drv_cancel_remain_on_channel(
  387. struct wpa_supplicant *wpa_s)
  388. {
  389. if (wpa_s->driver->cancel_remain_on_channel)
  390. return wpa_s->driver->cancel_remain_on_channel(
  391. wpa_s->drv_priv);
  392. return -1;
  393. }
  394. static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
  395. int report)
  396. {
  397. if (wpa_s->driver->probe_req_report)
  398. return wpa_s->driver->probe_req_report(wpa_s->drv_priv,
  399. report);
  400. return -1;
  401. }
  402. static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
  403. {
  404. if (wpa_s->driver->deinit_ap)
  405. return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
  406. return 0;
  407. }
  408. static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
  409. {
  410. if (wpa_s->driver->deinit_p2p_cli)
  411. return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
  412. return 0;
  413. }
  414. static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
  415. {
  416. if (wpa_s->driver->suspend)
  417. wpa_s->driver->suspend(wpa_s->drv_priv);
  418. }
  419. static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
  420. {
  421. if (wpa_s->driver->resume)
  422. wpa_s->driver->resume(wpa_s->drv_priv);
  423. }
  424. static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
  425. int threshold, int hysteresis)
  426. {
  427. if (wpa_s->driver->signal_monitor)
  428. return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
  429. threshold, hysteresis);
  430. return -1;
  431. }
  432. static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
  433. struct wpa_signal_info *si)
  434. {
  435. if (wpa_s->driver->signal_poll)
  436. return wpa_s->driver->signal_poll(wpa_s->drv_priv, si);
  437. return -1;
  438. }
  439. static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
  440. struct hostap_sta_driver_data *sta)
  441. {
  442. if (wpa_s->driver->read_sta_data)
  443. return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
  444. wpa_s->bssid);
  445. return -1;
  446. }
  447. static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
  448. const struct wpabuf *beacon,
  449. const struct wpabuf *proberesp,
  450. const struct wpabuf *assocresp)
  451. {
  452. if (!wpa_s->driver->set_ap_wps_ie)
  453. return -1;
  454. return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
  455. proberesp, assocresp);
  456. }
  457. static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
  458. u8 *buf, size_t buf_len)
  459. {
  460. if (!wpa_s->driver->get_noa)
  461. return -1;
  462. return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
  463. }
  464. static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
  465. int legacy_ps, int opp_ps,
  466. int ctwindow)
  467. {
  468. if (!wpa_s->driver->set_p2p_powersave)
  469. return -1;
  470. return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
  471. opp_ps, ctwindow);
  472. }
  473. static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
  474. {
  475. if (!wpa_s->driver->ampdu)
  476. return -1;
  477. return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
  478. }
  479. static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
  480. const u8 *dst, u8 action_code,
  481. u8 dialog_token, u16 status_code,
  482. u32 peer_capab, int initiator,
  483. const u8 *buf, size_t len)
  484. {
  485. if (wpa_s->driver->send_tdls_mgmt) {
  486. return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
  487. action_code, dialog_token,
  488. status_code, peer_capab,
  489. initiator, buf, len);
  490. }
  491. return -1;
  492. }
  493. static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
  494. enum tdls_oper oper, const u8 *peer)
  495. {
  496. if (!wpa_s->driver->tdls_oper)
  497. return -1;
  498. return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
  499. }
  500. #ifdef ANDROID
  501. static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
  502. char *cmd, char *buf, size_t buf_len)
  503. {
  504. if (!wpa_s->driver->driver_cmd)
  505. return -1;
  506. return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
  507. }
  508. #endif /* ANDROID */
  509. static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
  510. const u8 *kek, size_t kek_len,
  511. const u8 *kck, size_t kck_len,
  512. const u8 *replay_ctr)
  513. {
  514. if (!wpa_s->driver->set_rekey_info)
  515. return;
  516. wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kek_len,
  517. kck, kck_len, replay_ctr);
  518. }
  519. static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
  520. int disabled)
  521. {
  522. if (!wpa_s->driver->radio_disable)
  523. return -1;
  524. return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
  525. }
  526. static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
  527. struct csa_settings *settings)
  528. {
  529. if (!wpa_s->driver->switch_channel)
  530. return -1;
  531. return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings);
  532. }
  533. static inline int wpa_drv_add_ts(struct wpa_supplicant *wpa_s, u8 tsid,
  534. const u8 *address, u8 user_priority,
  535. u16 admitted_time)
  536. {
  537. if (!wpa_s->driver->add_tx_ts)
  538. return -1;
  539. return wpa_s->driver->add_tx_ts(wpa_s->drv_priv, tsid, address,
  540. user_priority, admitted_time);
  541. }
  542. static inline int wpa_drv_del_ts(struct wpa_supplicant *wpa_s, u8 tid,
  543. const u8 *address)
  544. {
  545. if (!wpa_s->driver->del_tx_ts)
  546. return -1;
  547. return wpa_s->driver->del_tx_ts(wpa_s->drv_priv, tid, address);
  548. }
  549. static inline int wpa_drv_tdls_enable_channel_switch(
  550. struct wpa_supplicant *wpa_s, const u8 *addr, u8 oper_class,
  551. const struct hostapd_freq_params *freq_params)
  552. {
  553. if (!wpa_s->driver->tdls_enable_channel_switch)
  554. return -1;
  555. return wpa_s->driver->tdls_enable_channel_switch(wpa_s->drv_priv, addr,
  556. oper_class,
  557. freq_params);
  558. }
  559. static inline int
  560. wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant *wpa_s,
  561. const u8 *addr)
  562. {
  563. if (!wpa_s->driver->tdls_disable_channel_switch)
  564. return -1;
  565. return wpa_s->driver->tdls_disable_channel_switch(wpa_s->drv_priv,
  566. addr);
  567. }
  568. static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
  569. enum wnm_oper oper, const u8 *peer,
  570. u8 *buf, u16 *buf_len)
  571. {
  572. if (!wpa_s->driver->wnm_oper)
  573. return -1;
  574. return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
  575. buf_len);
  576. }
  577. static inline int wpa_drv_status(struct wpa_supplicant *wpa_s,
  578. char *buf, size_t buflen)
  579. {
  580. if (!wpa_s->driver->status)
  581. return -1;
  582. return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen);
  583. }
  584. static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s,
  585. const u8 *qos_map_set, u8 qos_map_set_len)
  586. {
  587. if (!wpa_s->driver->set_qos_map)
  588. return -1;
  589. return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set,
  590. qos_map_set_len);
  591. }
  592. static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s,
  593. const struct wowlan_triggers *triggers)
  594. {
  595. if (!wpa_s->driver->set_wowlan)
  596. return -1;
  597. return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers);
  598. }
  599. static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
  600. int vendor_id, int subcmd, const u8 *data,
  601. size_t data_len, struct wpabuf *buf)
  602. {
  603. if (!wpa_s->driver->vendor_cmd)
  604. return -1;
  605. return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd,
  606. data, data_len, buf);
  607. }
  608. static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed,
  609. const u8 *bssid)
  610. {
  611. if (!wpa_s->driver->roaming)
  612. return -1;
  613. return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid);
  614. }
  615. static inline int wpa_drv_disable_fils(struct wpa_supplicant *wpa_s,
  616. int disable)
  617. {
  618. if (!wpa_s->driver->disable_fils)
  619. return -1;
  620. return wpa_s->driver->disable_fils(wpa_s->drv_priv, disable);
  621. }
  622. static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s,
  623. const u8 *addr)
  624. {
  625. if (!wpa_s->driver->set_mac_addr)
  626. return -1;
  627. return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr);
  628. }
  629. #ifdef CONFIG_MACSEC
  630. static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
  631. struct macsec_init_params *params)
  632. {
  633. if (!wpa_s->driver->macsec_init)
  634. return -1;
  635. return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
  636. }
  637. static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
  638. {
  639. if (!wpa_s->driver->macsec_deinit)
  640. return -1;
  641. return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
  642. }
  643. static inline int wpa_drv_macsec_get_capability(struct wpa_supplicant *wpa_s,
  644. enum macsec_cap *cap)
  645. {
  646. if (!wpa_s->driver->macsec_get_capability)
  647. return -1;
  648. return wpa_s->driver->macsec_get_capability(wpa_s->drv_priv, cap);
  649. }
  650. static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
  651. Boolean enabled)
  652. {
  653. if (!wpa_s->driver->enable_protect_frames)
  654. return -1;
  655. return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
  656. }
  657. static inline int wpa_drv_enable_encrypt(struct wpa_supplicant *wpa_s,
  658. Boolean enabled)
  659. {
  660. if (!wpa_s->driver->enable_encrypt)
  661. return -1;
  662. return wpa_s->driver->enable_encrypt(wpa_s->drv_priv, enabled);
  663. }
  664. static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
  665. Boolean enabled, u32 window)
  666. {
  667. if (!wpa_s->driver->set_replay_protect)
  668. return -1;
  669. return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
  670. window);
  671. }
  672. static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
  673. u64 cs)
  674. {
  675. if (!wpa_s->driver->set_current_cipher_suite)
  676. return -1;
  677. return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs);
  678. }
  679. static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
  680. Boolean enabled)
  681. {
  682. if (!wpa_s->driver->enable_controlled_port)
  683. return -1;
  684. return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
  685. }
  686. static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
  687. struct receive_sa *sa)
  688. {
  689. if (!wpa_s->driver->get_receive_lowest_pn)
  690. return -1;
  691. return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
  692. }
  693. static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
  694. struct transmit_sa *sa)
  695. {
  696. if (!wpa_s->driver->get_transmit_next_pn)
  697. return -1;
  698. return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
  699. }
  700. static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
  701. struct transmit_sa *sa)
  702. {
  703. if (!wpa_s->driver->set_transmit_next_pn)
  704. return -1;
  705. return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
  706. }
  707. static inline int
  708. wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc,
  709. unsigned int conf_offset, int validation)
  710. {
  711. if (!wpa_s->driver->create_receive_sc)
  712. return -1;
  713. return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc,
  714. conf_offset, validation);
  715. }
  716. static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
  717. struct receive_sc *sc)
  718. {
  719. if (!wpa_s->driver->delete_receive_sc)
  720. return -1;
  721. return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc);
  722. }
  723. static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
  724. struct receive_sa *sa)
  725. {
  726. if (!wpa_s->driver->create_receive_sa)
  727. return -1;
  728. return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
  729. }
  730. static inline int wpa_drv_delete_receive_sa(struct wpa_supplicant *wpa_s,
  731. struct receive_sa *sa)
  732. {
  733. if (!wpa_s->driver->delete_receive_sa)
  734. return -1;
  735. return wpa_s->driver->delete_receive_sa(wpa_s->drv_priv, sa);
  736. }
  737. static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
  738. struct receive_sa *sa)
  739. {
  740. if (!wpa_s->driver->enable_receive_sa)
  741. return -1;
  742. return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
  743. }
  744. static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
  745. struct receive_sa *sa)
  746. {
  747. if (!wpa_s->driver->disable_receive_sa)
  748. return -1;
  749. return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
  750. }
  751. static inline int
  752. wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, struct transmit_sc *sc,
  753. unsigned int conf_offset)
  754. {
  755. if (!wpa_s->driver->create_transmit_sc)
  756. return -1;
  757. return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, sc,
  758. conf_offset);
  759. }
  760. static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
  761. struct transmit_sc *sc)
  762. {
  763. if (!wpa_s->driver->delete_transmit_sc)
  764. return -1;
  765. return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, sc);
  766. }
  767. static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
  768. struct transmit_sa *sa)
  769. {
  770. if (!wpa_s->driver->create_transmit_sa)
  771. return -1;
  772. return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, sa);
  773. }
  774. static inline int wpa_drv_delete_transmit_sa(struct wpa_supplicant *wpa_s,
  775. struct transmit_sa *sa)
  776. {
  777. if (!wpa_s->driver->delete_transmit_sa)
  778. return -1;
  779. return wpa_s->driver->delete_transmit_sa(wpa_s->drv_priv, sa);
  780. }
  781. static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
  782. struct transmit_sa *sa)
  783. {
  784. if (!wpa_s->driver->enable_transmit_sa)
  785. return -1;
  786. return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, sa);
  787. }
  788. static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
  789. struct transmit_sa *sa)
  790. {
  791. if (!wpa_s->driver->disable_transmit_sa)
  792. return -1;
  793. return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, sa);
  794. }
  795. #endif /* CONFIG_MACSEC */
  796. static inline int wpa_drv_setband(struct wpa_supplicant *wpa_s,
  797. enum set_band band)
  798. {
  799. if (!wpa_s->driver->set_band)
  800. return -1;
  801. return wpa_s->driver->set_band(wpa_s->drv_priv, band);
  802. }
  803. static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s,
  804. enum wpa_driver_if_type if_type,
  805. unsigned int *num,
  806. unsigned int *freq_list)
  807. {
  808. #ifdef CONFIG_TESTING_OPTIONS
  809. if (wpa_s->get_pref_freq_list_override)
  810. return wpas_ctrl_iface_get_pref_freq_list_override(
  811. wpa_s, if_type, num, freq_list);
  812. #endif /* CONFIG_TESTING_OPTIONS */
  813. if (!wpa_s->driver->get_pref_freq_list)
  814. return -1;
  815. return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type,
  816. num, freq_list);
  817. }
  818. static inline int wpa_drv_set_prob_oper_freq(struct wpa_supplicant *wpa_s,
  819. unsigned int freq)
  820. {
  821. if (!wpa_s->driver->set_prob_oper_freq)
  822. return 0;
  823. return wpa_s->driver->set_prob_oper_freq(wpa_s->drv_priv, freq);
  824. }
  825. static inline int wpa_drv_abort_scan(struct wpa_supplicant *wpa_s,
  826. u64 scan_cookie)
  827. {
  828. if (!wpa_s->driver->abort_scan)
  829. return -1;
  830. return wpa_s->driver->abort_scan(wpa_s->drv_priv, scan_cookie);
  831. }
  832. static inline int wpa_drv_configure_frame_filters(struct wpa_supplicant *wpa_s,
  833. u32 filters)
  834. {
  835. if (!wpa_s->driver->configure_data_frame_filters)
  836. return -1;
  837. return wpa_s->driver->configure_data_frame_filters(wpa_s->drv_priv,
  838. filters);
  839. }
  840. static inline int wpa_drv_get_ext_capa(struct wpa_supplicant *wpa_s,
  841. enum wpa_driver_if_type type)
  842. {
  843. if (!wpa_s->driver->get_ext_capab)
  844. return -1;
  845. return wpa_s->driver->get_ext_capab(wpa_s->drv_priv, type,
  846. &wpa_s->extended_capa,
  847. &wpa_s->extended_capa_mask,
  848. &wpa_s->extended_capa_len);
  849. }
  850. static inline int wpa_drv_p2p_lo_start(struct wpa_supplicant *wpa_s,
  851. unsigned int channel,
  852. unsigned int period,
  853. unsigned int interval,
  854. unsigned int count,
  855. const u8 *device_types,
  856. size_t dev_types_len,
  857. const u8 *ies, size_t ies_len)
  858. {
  859. if (!wpa_s->driver->p2p_lo_start)
  860. return -1;
  861. return wpa_s->driver->p2p_lo_start(wpa_s->drv_priv, channel, period,
  862. interval, count, device_types,
  863. dev_types_len, ies, ies_len);
  864. }
  865. static inline int wpa_drv_p2p_lo_stop(struct wpa_supplicant *wpa_s)
  866. {
  867. if (!wpa_s->driver->p2p_lo_stop)
  868. return -1;
  869. return wpa_s->driver->p2p_lo_stop(wpa_s->drv_priv);
  870. }
  871. static inline int wpa_drv_set_default_scan_ies(struct wpa_supplicant *wpa_s,
  872. const u8 *ies, size_t len)
  873. {
  874. if (!wpa_s->driver->set_default_scan_ies)
  875. return -1;
  876. return wpa_s->driver->set_default_scan_ies(wpa_s->drv_priv, ies, len);
  877. }
  878. static inline int wpa_drv_set_tdls_mode(struct wpa_supplicant *wpa_s,
  879. int tdls_external_control)
  880. {
  881. if (!wpa_s->driver->set_tdls_mode)
  882. return -1;
  883. return wpa_s->driver->set_tdls_mode(wpa_s->drv_priv,
  884. tdls_external_control);
  885. }
  886. static inline struct wpa_bss_candidate_info *
  887. wpa_drv_get_bss_trans_status(struct wpa_supplicant *wpa_s,
  888. struct wpa_bss_trans_info *params)
  889. {
  890. if (!wpa_s->driver->get_bss_transition_status)
  891. return NULL;
  892. return wpa_s->driver->get_bss_transition_status(wpa_s->drv_priv,
  893. params);
  894. }
  895. static inline int wpa_drv_ignore_assoc_disallow(struct wpa_supplicant *wpa_s,
  896. int val)
  897. {
  898. if (!wpa_s->driver->ignore_assoc_disallow)
  899. return -1;
  900. return wpa_s->driver->ignore_assoc_disallow(wpa_s->drv_priv, val);
  901. }
  902. static inline int wpa_drv_set_bssid_blacklist(struct wpa_supplicant *wpa_s,
  903. unsigned int num_bssid,
  904. const u8 *bssids)
  905. {
  906. if (!wpa_s->driver->set_bssid_blacklist)
  907. return -1;
  908. return wpa_s->driver->set_bssid_blacklist(wpa_s->drv_priv, num_bssid,
  909. bssids);
  910. }
  911. static inline int wpa_drv_update_connect_params(
  912. struct wpa_supplicant *wpa_s,
  913. struct wpa_driver_associate_params *params,
  914. enum wpa_drv_update_connect_params_mask mask)
  915. {
  916. if (!wpa_s->driver->update_connect_params)
  917. return -1;
  918. return wpa_s->driver->update_connect_params(wpa_s->drv_priv, params,
  919. mask);
  920. }
  921. static inline int
  922. wpa_drv_send_external_auth_status(struct wpa_supplicant *wpa_s,
  923. struct external_auth *params)
  924. {
  925. if (!wpa_s->driver->send_external_auth_status)
  926. return -1;
  927. return wpa_s->driver->send_external_auth_status(wpa_s->drv_priv,
  928. params);
  929. }
  930. #endif /* DRIVER_I_H */