driver_i.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. /*
  2. * wpa_supplicant - Internal driver interface wrappers
  3. * Copyright (c) 2003-2009, 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. if (wpa_s->driver->scan2)
  82. return wpa_s->driver->scan2(wpa_s->drv_priv, params);
  83. return -1;
  84. }
  85. static inline int wpa_drv_sched_scan(struct wpa_supplicant *wpa_s,
  86. struct wpa_driver_scan_params *params,
  87. u32 interval)
  88. {
  89. if (wpa_s->driver->sched_scan)
  90. return wpa_s->driver->sched_scan(wpa_s->drv_priv,
  91. params, interval);
  92. return -1;
  93. }
  94. static inline int wpa_drv_stop_sched_scan(struct wpa_supplicant *wpa_s)
  95. {
  96. if (wpa_s->driver->stop_sched_scan)
  97. return wpa_s->driver->stop_sched_scan(wpa_s->drv_priv);
  98. return -1;
  99. }
  100. static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
  101. struct wpa_supplicant *wpa_s)
  102. {
  103. if (wpa_s->driver->get_scan_results2)
  104. return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
  105. return NULL;
  106. }
  107. static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
  108. {
  109. if (wpa_s->driver->get_bssid) {
  110. return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
  111. }
  112. return -1;
  113. }
  114. static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
  115. {
  116. if (wpa_s->driver->get_ssid) {
  117. return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
  118. }
  119. return -1;
  120. }
  121. static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s,
  122. enum wpa_alg alg, const u8 *addr,
  123. int key_idx, int set_tx,
  124. const u8 *seq, size_t seq_len,
  125. const u8 *key, size_t key_len)
  126. {
  127. if (alg != WPA_ALG_NONE) {
  128. if (key_idx >= 0 && key_idx <= 6)
  129. wpa_s->keys_cleared &= ~BIT(key_idx);
  130. else
  131. wpa_s->keys_cleared = 0;
  132. }
  133. if (wpa_s->driver->set_key) {
  134. return wpa_s->driver->set_key(wpa_s->ifname, wpa_s->drv_priv,
  135. alg, addr, key_idx, set_tx,
  136. seq, seq_len, key, key_len);
  137. }
  138. return -1;
  139. }
  140. static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
  141. const u8 *addr, int reason_code)
  142. {
  143. if (wpa_s->driver->sta_deauth) {
  144. return wpa_s->driver->sta_deauth(wpa_s->drv_priv,
  145. wpa_s->own_addr, addr,
  146. reason_code);
  147. }
  148. return -1;
  149. }
  150. static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
  151. const u8 *addr, int reason_code)
  152. {
  153. if (wpa_s->driver->deauthenticate) {
  154. return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
  155. reason_code);
  156. }
  157. return -1;
  158. }
  159. static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
  160. const u8 *bssid, const u8 *pmkid)
  161. {
  162. if (wpa_s->driver->add_pmkid) {
  163. return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
  164. }
  165. return -1;
  166. }
  167. static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
  168. const u8 *bssid, const u8 *pmkid)
  169. {
  170. if (wpa_s->driver->remove_pmkid) {
  171. return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
  172. pmkid);
  173. }
  174. return -1;
  175. }
  176. static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
  177. {
  178. if (wpa_s->driver->flush_pmkid) {
  179. return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
  180. }
  181. return -1;
  182. }
  183. static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
  184. struct wpa_driver_capa *capa)
  185. {
  186. if (wpa_s->driver->get_capa) {
  187. return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
  188. }
  189. return -1;
  190. }
  191. static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
  192. {
  193. if (wpa_s->driver->poll) {
  194. wpa_s->driver->poll(wpa_s->drv_priv);
  195. }
  196. }
  197. static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
  198. {
  199. if (wpa_s->driver->get_ifname) {
  200. return wpa_s->driver->get_ifname(wpa_s->drv_priv);
  201. }
  202. return NULL;
  203. }
  204. static inline const char *
  205. wpa_driver_get_radio_name(struct wpa_supplicant *wpa_s)
  206. {
  207. if (wpa_s->driver->get_radio_name)
  208. return wpa_s->driver->get_radio_name(wpa_s->drv_priv);
  209. return NULL;
  210. }
  211. static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
  212. {
  213. if (wpa_s->driver->get_mac_addr) {
  214. return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
  215. }
  216. return NULL;
  217. }
  218. static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
  219. const u8 *dst, u16 proto,
  220. const u8 *data, size_t data_len)
  221. {
  222. if (wpa_s->driver->send_eapol)
  223. return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
  224. data, data_len);
  225. return -1;
  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)
  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. return NULL;
  252. }
  253. static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
  254. const char *alpha2)
  255. {
  256. if (wpa_s->driver->set_country)
  257. return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
  258. return 0;
  259. }
  260. static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
  261. const u8 *data, size_t data_len, int noack)
  262. {
  263. if (wpa_s->driver->send_mlme)
  264. return wpa_s->driver->send_mlme(wpa_s->drv_priv,
  265. data, data_len, noack);
  266. return -1;
  267. }
  268. static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
  269. const u8 *md,
  270. const u8 *ies, size_t ies_len)
  271. {
  272. if (wpa_s->driver->update_ft_ies)
  273. return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
  274. ies, ies_len);
  275. return -1;
  276. }
  277. static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
  278. u8 action, const u8 *target_ap,
  279. const u8 *ies, size_t ies_len)
  280. {
  281. if (wpa_s->driver->send_ft_action)
  282. return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
  283. target_ap, ies, ies_len);
  284. return -1;
  285. }
  286. static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
  287. struct wpa_driver_ap_params *params)
  288. {
  289. if (wpa_s->driver->set_ap)
  290. return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
  291. return -1;
  292. }
  293. static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s,
  294. struct hostapd_sta_add_params *params)
  295. {
  296. if (wpa_s->driver->sta_add)
  297. return wpa_s->driver->sta_add(wpa_s->drv_priv, params);
  298. return -1;
  299. }
  300. static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s,
  301. const u8 *addr)
  302. {
  303. if (wpa_s->driver->sta_remove)
  304. return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr);
  305. return -1;
  306. }
  307. static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
  308. const u8 *addr, const u8 *data,
  309. size_t data_len, int encrypt,
  310. const u8 *own_addr, u32 flags)
  311. {
  312. if (wpa_s->driver->hapd_send_eapol)
  313. return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
  314. data, data_len, encrypt,
  315. own_addr, flags);
  316. return -1;
  317. }
  318. static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s,
  319. const u8 *addr, int total_flags,
  320. int flags_or, int flags_and)
  321. {
  322. if (wpa_s->driver->sta_set_flags)
  323. return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr,
  324. total_flags, flags_or,
  325. flags_and);
  326. return -1;
  327. }
  328. static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
  329. int authorized)
  330. {
  331. if (wpa_s->driver->set_supp_port) {
  332. return wpa_s->driver->set_supp_port(wpa_s->drv_priv,
  333. authorized);
  334. }
  335. return 0;
  336. }
  337. static inline int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
  338. unsigned int freq,
  339. unsigned int wait,
  340. const u8 *dst, const u8 *src,
  341. const u8 *bssid,
  342. const u8 *data, size_t data_len,
  343. int no_cck)
  344. {
  345. if (wpa_s->driver->send_action)
  346. return wpa_s->driver->send_action(wpa_s->drv_priv, freq,
  347. wait, dst, src, bssid,
  348. data, data_len, no_cck);
  349. return -1;
  350. }
  351. static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s)
  352. {
  353. if (wpa_s->driver->send_action_cancel_wait)
  354. wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv);
  355. }
  356. static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s,
  357. struct hostapd_freq_params *freq)
  358. {
  359. if (wpa_s->driver->set_freq)
  360. return wpa_s->driver->set_freq(wpa_s->drv_priv, freq);
  361. return -1;
  362. }
  363. static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
  364. enum wpa_driver_if_type type,
  365. const char *ifname, const u8 *addr,
  366. void *bss_ctx, char *force_ifname,
  367. u8 *if_addr, const char *bridge)
  368. {
  369. if (wpa_s->driver->if_add)
  370. return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
  371. addr, bss_ctx, NULL, force_ifname,
  372. if_addr, bridge, 0);
  373. return -1;
  374. }
  375. static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s,
  376. enum wpa_driver_if_type type,
  377. const char *ifname)
  378. {
  379. if (wpa_s->driver->if_remove)
  380. return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname);
  381. return -1;
  382. }
  383. static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s,
  384. unsigned int freq,
  385. unsigned int duration)
  386. {
  387. if (wpa_s->driver->remain_on_channel)
  388. return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq,
  389. duration);
  390. return -1;
  391. }
  392. static inline int wpa_drv_cancel_remain_on_channel(
  393. struct wpa_supplicant *wpa_s)
  394. {
  395. if (wpa_s->driver->cancel_remain_on_channel)
  396. return wpa_s->driver->cancel_remain_on_channel(
  397. wpa_s->drv_priv);
  398. return -1;
  399. }
  400. static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
  401. int report)
  402. {
  403. if (wpa_s->driver->probe_req_report)
  404. return wpa_s->driver->probe_req_report(wpa_s->drv_priv,
  405. report);
  406. return -1;
  407. }
  408. static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
  409. {
  410. if (wpa_s->driver->deinit_ap)
  411. return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
  412. return 0;
  413. }
  414. static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
  415. {
  416. if (wpa_s->driver->deinit_p2p_cli)
  417. return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
  418. return 0;
  419. }
  420. static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
  421. {
  422. if (wpa_s->driver->suspend)
  423. wpa_s->driver->suspend(wpa_s->drv_priv);
  424. }
  425. static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
  426. {
  427. if (wpa_s->driver->resume)
  428. wpa_s->driver->resume(wpa_s->drv_priv);
  429. }
  430. static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
  431. int threshold, int hysteresis)
  432. {
  433. if (wpa_s->driver->signal_monitor)
  434. return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
  435. threshold, hysteresis);
  436. return -1;
  437. }
  438. static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
  439. struct wpa_signal_info *si)
  440. {
  441. if (wpa_s->driver->signal_poll)
  442. return wpa_s->driver->signal_poll(wpa_s->drv_priv, si);
  443. return -1;
  444. }
  445. static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
  446. struct hostap_sta_driver_data *sta)
  447. {
  448. if (wpa_s->driver->read_sta_data)
  449. return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
  450. wpa_s->bssid);
  451. return -1;
  452. }
  453. static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
  454. const struct wpabuf *beacon,
  455. const struct wpabuf *proberesp,
  456. const struct wpabuf *assocresp)
  457. {
  458. if (!wpa_s->driver->set_ap_wps_ie)
  459. return -1;
  460. return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
  461. proberesp, assocresp);
  462. }
  463. static inline int wpa_drv_shared_freq(struct wpa_supplicant *wpa_s)
  464. {
  465. if (!wpa_s->driver->shared_freq)
  466. return -1;
  467. return wpa_s->driver->shared_freq(wpa_s->drv_priv);
  468. }
  469. static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
  470. u8 *buf, size_t buf_len)
  471. {
  472. if (!wpa_s->driver->get_noa)
  473. return -1;
  474. return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
  475. }
  476. static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
  477. int legacy_ps, int opp_ps,
  478. int ctwindow)
  479. {
  480. if (!wpa_s->driver->set_p2p_powersave)
  481. return -1;
  482. return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
  483. opp_ps, ctwindow);
  484. }
  485. static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
  486. {
  487. if (!wpa_s->driver->ampdu)
  488. return -1;
  489. return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
  490. }
  491. static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
  492. const u8 *dst, u8 action_code,
  493. u8 dialog_token, u16 status_code,
  494. u32 peer_capab, int initiator,
  495. const u8 *buf, size_t len)
  496. {
  497. if (wpa_s->driver->send_tdls_mgmt) {
  498. return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
  499. action_code, dialog_token,
  500. status_code, peer_capab,
  501. initiator, buf, len);
  502. }
  503. return -1;
  504. }
  505. static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
  506. enum tdls_oper oper, const u8 *peer)
  507. {
  508. if (!wpa_s->driver->tdls_oper)
  509. return -1;
  510. return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
  511. }
  512. #ifdef ANDROID
  513. static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
  514. char *cmd, char *buf, size_t buf_len)
  515. {
  516. if (!wpa_s->driver->driver_cmd)
  517. return -1;
  518. return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
  519. }
  520. #endif /* ANDROID */
  521. static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
  522. const u8 *kek, const u8 *kck,
  523. const u8 *replay_ctr)
  524. {
  525. if (!wpa_s->driver->set_rekey_info)
  526. return;
  527. wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kck, replay_ctr);
  528. }
  529. static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
  530. int disabled)
  531. {
  532. if (!wpa_s->driver->radio_disable)
  533. return -1;
  534. return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
  535. }
  536. static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
  537. struct csa_settings *settings)
  538. {
  539. if (!wpa_s->driver->switch_channel)
  540. return -1;
  541. return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings);
  542. }
  543. static inline int wpa_drv_add_ts(struct wpa_supplicant *wpa_s, u8 tsid,
  544. const u8 *address, u8 user_priority,
  545. u16 admitted_time)
  546. {
  547. if (!wpa_s->driver->add_tx_ts)
  548. return -1;
  549. return wpa_s->driver->add_tx_ts(wpa_s->drv_priv, tsid, address,
  550. user_priority, admitted_time);
  551. }
  552. static inline int wpa_drv_del_ts(struct wpa_supplicant *wpa_s, u8 tid,
  553. const u8 *address)
  554. {
  555. if (!wpa_s->driver->del_tx_ts)
  556. return -1;
  557. return wpa_s->driver->del_tx_ts(wpa_s->drv_priv, tid, address);
  558. }
  559. static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
  560. enum wnm_oper oper, const u8 *peer,
  561. u8 *buf, u16 *buf_len)
  562. {
  563. if (!wpa_s->driver->wnm_oper)
  564. return -1;
  565. return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
  566. buf_len);
  567. }
  568. static inline int wpa_drv_status(struct wpa_supplicant *wpa_s,
  569. char *buf, size_t buflen)
  570. {
  571. if (!wpa_s->driver->status)
  572. return -1;
  573. return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen);
  574. }
  575. static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s,
  576. const u8 *qos_map_set, u8 qos_map_set_len)
  577. {
  578. if (!wpa_s->driver->set_qos_map)
  579. return -1;
  580. return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set,
  581. qos_map_set_len);
  582. }
  583. static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s,
  584. const struct wowlan_triggers *triggers)
  585. {
  586. if (!wpa_s->driver->set_wowlan)
  587. return -1;
  588. return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers);
  589. }
  590. static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
  591. int vendor_id, int subcmd, const u8 *data,
  592. size_t data_len, struct wpabuf *buf)
  593. {
  594. if (!wpa_s->driver->vendor_cmd)
  595. return -1;
  596. return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd,
  597. data, data_len, buf);
  598. }
  599. static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed,
  600. const u8 *bssid)
  601. {
  602. if (!wpa_s->driver->roaming)
  603. return -1;
  604. return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid);
  605. }
  606. static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s,
  607. const u8 *addr)
  608. {
  609. if (!wpa_s->driver->set_mac_addr)
  610. return -1;
  611. return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr);
  612. }
  613. #ifdef CONFIG_MACSEC
  614. static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
  615. struct macsec_init_params *params)
  616. {
  617. if (!wpa_s->driver->macsec_init)
  618. return -1;
  619. return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
  620. }
  621. static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
  622. {
  623. if (!wpa_s->driver->macsec_deinit)
  624. return -1;
  625. return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
  626. }
  627. static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
  628. Boolean enabled)
  629. {
  630. if (!wpa_s->driver->enable_protect_frames)
  631. return -1;
  632. return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
  633. }
  634. static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
  635. Boolean enabled, u32 window)
  636. {
  637. if (!wpa_s->driver->set_replay_protect)
  638. return -1;
  639. return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
  640. window);
  641. }
  642. static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
  643. const u8 *cs, size_t cs_len)
  644. {
  645. if (!wpa_s->driver->set_current_cipher_suite)
  646. return -1;
  647. return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs,
  648. cs_len);
  649. }
  650. static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
  651. Boolean enabled)
  652. {
  653. if (!wpa_s->driver->enable_controlled_port)
  654. return -1;
  655. return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
  656. }
  657. static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
  658. u32 channel, u8 an,
  659. u32 *lowest_pn)
  660. {
  661. if (!wpa_s->driver->get_receive_lowest_pn)
  662. return -1;
  663. return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, channel,
  664. an, lowest_pn);
  665. }
  666. static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
  667. u32 channel, u8 an,
  668. u32 *next_pn)
  669. {
  670. if (!wpa_s->driver->get_transmit_next_pn)
  671. return -1;
  672. return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, channel,
  673. an, next_pn);
  674. }
  675. static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
  676. u32 channel, u8 an,
  677. u32 next_pn)
  678. {
  679. if (!wpa_s->driver->set_transmit_next_pn)
  680. return -1;
  681. return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, channel,
  682. an, next_pn);
  683. }
  684. static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
  685. u32 *channel)
  686. {
  687. if (!wpa_s->driver->get_available_receive_sc)
  688. return -1;
  689. return wpa_s->driver->get_available_receive_sc(wpa_s->drv_priv,
  690. channel);
  691. }
  692. static inline int
  693. wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, u32 channel,
  694. const u8 *sci_addr, u16 sci_port,
  695. unsigned int conf_offset, int validation)
  696. {
  697. if (!wpa_s->driver->create_receive_sc)
  698. return -1;
  699. return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, channel,
  700. sci_addr, sci_port, conf_offset,
  701. validation);
  702. }
  703. static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
  704. u32 channel)
  705. {
  706. if (!wpa_s->driver->delete_receive_sc)
  707. return -1;
  708. return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, channel);
  709. }
  710. static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
  711. u32 channel, u8 an,
  712. u32 lowest_pn, const u8 *sak)
  713. {
  714. if (!wpa_s->driver->create_receive_sa)
  715. return -1;
  716. return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, channel, an,
  717. lowest_pn, sak);
  718. }
  719. static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
  720. u32 channel, u8 an)
  721. {
  722. if (!wpa_s->driver->enable_receive_sa)
  723. return -1;
  724. return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, channel, an);
  725. }
  726. static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
  727. u32 channel, u8 an)
  728. {
  729. if (!wpa_s->driver->disable_receive_sa)
  730. return -1;
  731. return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, channel, an);
  732. }
  733. static inline int
  734. wpa_drv_get_available_transmit_sc(struct wpa_supplicant *wpa_s, u32 *channel)
  735. {
  736. if (!wpa_s->driver->get_available_transmit_sc)
  737. return -1;
  738. return wpa_s->driver->get_available_transmit_sc(wpa_s->drv_priv,
  739. channel);
  740. }
  741. static inline int
  742. wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, u32 channel,
  743. const u8 *sci_addr, u16 sci_port,
  744. unsigned int conf_offset)
  745. {
  746. if (!wpa_s->driver->create_transmit_sc)
  747. return -1;
  748. return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, channel,
  749. sci_addr, sci_port,
  750. conf_offset);
  751. }
  752. static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
  753. u32 channel)
  754. {
  755. if (!wpa_s->driver->delete_transmit_sc)
  756. return -1;
  757. return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, channel);
  758. }
  759. static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
  760. u32 channel, u8 an,
  761. u32 next_pn,
  762. Boolean confidentiality,
  763. const u8 *sak)
  764. {
  765. if (!wpa_s->driver->create_transmit_sa)
  766. return -1;
  767. return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, channel, an,
  768. next_pn, confidentiality, sak);
  769. }
  770. static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
  771. u32 channel, u8 an)
  772. {
  773. if (!wpa_s->driver->enable_transmit_sa)
  774. return -1;
  775. return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, channel, an);
  776. }
  777. static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
  778. u32 channel, u8 an)
  779. {
  780. if (!wpa_s->driver->disable_transmit_sa)
  781. return -1;
  782. return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, channel, an);
  783. }
  784. #endif /* CONFIG_MACSEC */
  785. #endif /* DRIVER_I_H */