wpa_supplicant_i.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /*
  2. * wpa_supplicant - Internal definitions
  3. * Copyright (c) 2003-2007, 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 WPA_SUPPLICANT_I_H
  15. #define WPA_SUPPLICANT_I_H
  16. #include "drivers/driver.h"
  17. struct wpa_scan_result;
  18. struct wpa_sm;
  19. struct wpa_supplicant;
  20. /*
  21. * Forward declarations of private structures used within the ctrl_iface
  22. * backends. Other parts of wpa_supplicant do not have access to data stored in
  23. * these structures.
  24. */
  25. struct ctrl_iface_priv;
  26. struct ctrl_iface_global_priv;
  27. struct ctrl_iface_dbus_priv;
  28. /**
  29. * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
  30. */
  31. struct wpa_interface {
  32. /**
  33. * confname - Configuration name (file or profile) name
  34. *
  35. * This can also be %NULL when a configuration file is not used. In
  36. * that case, ctrl_interface must be set to allow the interface to be
  37. * configured.
  38. */
  39. const char *confname;
  40. /**
  41. * ctrl_interface - Control interface parameter
  42. *
  43. * If a configuration file is not used, this variable can be used to
  44. * set the ctrl_interface parameter that would have otherwise been read
  45. * from the configuration file. If both confname and ctrl_interface are
  46. * set, ctrl_interface is used to override the value from configuration
  47. * file.
  48. */
  49. const char *ctrl_interface;
  50. /**
  51. * driver - Driver interface name, or %NULL to use the default driver
  52. */
  53. const char *driver;
  54. /**
  55. * driver_param - Driver interface parameters
  56. *
  57. * If a configuration file is not used, this variable can be used to
  58. * set the driver_param parameters that would have otherwise been read
  59. * from the configuration file. If both confname and driver_param are
  60. * set, driver_param is used to override the value from configuration
  61. * file.
  62. */
  63. const char *driver_param;
  64. /**
  65. * ifname - Interface name
  66. */
  67. const char *ifname;
  68. /**
  69. * bridge_ifname - Optional bridge interface name
  70. *
  71. * If the driver interface (ifname) is included in a Linux bridge
  72. * device, the bridge interface may need to be used for receiving EAPOL
  73. * frames. This can be enabled by setting this variable to enable
  74. * receiving of EAPOL frames from an additional interface.
  75. */
  76. const char *bridge_ifname;
  77. };
  78. /**
  79. * struct wpa_params - Parameters for wpa_supplicant_init()
  80. */
  81. struct wpa_params {
  82. /**
  83. * daemonize - Run %wpa_supplicant in the background
  84. */
  85. int daemonize;
  86. /**
  87. * wait_for_monitor - Wait for a monitor program before starting
  88. */
  89. int wait_for_monitor;
  90. /**
  91. * pid_file - Path to a PID (process ID) file
  92. *
  93. * If this and daemonize are set, process ID of the background process
  94. * will be written to the specified file.
  95. */
  96. char *pid_file;
  97. /**
  98. * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
  99. */
  100. int wpa_debug_level;
  101. /**
  102. * wpa_debug_show_keys - Whether keying material is included in debug
  103. *
  104. * This parameter can be used to allow keying material to be included
  105. * in debug messages. This is a security risk and this option should
  106. * not be enabled in normal configuration. If needed during
  107. * development or while troubleshooting, this option can provide more
  108. * details for figuring out what is happening.
  109. */
  110. int wpa_debug_show_keys;
  111. /**
  112. * wpa_debug_timestamp - Whether to include timestamp in debug messages
  113. */
  114. int wpa_debug_timestamp;
  115. /**
  116. * ctrl_interface - Global ctrl_iface path/parameter
  117. */
  118. char *ctrl_interface;
  119. /**
  120. * dbus_ctrl_interface - Enable the DBus control interface
  121. */
  122. int dbus_ctrl_interface;
  123. /**
  124. * wpa_debug_file_path - Path of debug file or %NULL to use stdout
  125. */
  126. const char *wpa_debug_file_path;
  127. };
  128. /**
  129. * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
  130. *
  131. * This structure is initialized by calling wpa_supplicant_init() when starting
  132. * %wpa_supplicant.
  133. */
  134. struct wpa_global {
  135. struct wpa_supplicant *ifaces;
  136. struct wpa_params params;
  137. struct ctrl_iface_global_priv *ctrl_iface;
  138. struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
  139. };
  140. struct wpa_client_mlme {
  141. #ifdef CONFIG_CLIENT_MLME
  142. enum {
  143. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  144. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  145. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
  146. } state;
  147. u8 prev_bssid[ETH_ALEN];
  148. u8 ssid[32];
  149. size_t ssid_len;
  150. u16 aid;
  151. u16 ap_capab, capab;
  152. u8 *extra_ie; /* to be added to the end of AssocReq */
  153. size_t extra_ie_len;
  154. u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
  155. size_t extra_probe_ie_len;
  156. wpa_key_mgmt key_mgmt;
  157. /* The last AssocReq/Resp IEs */
  158. u8 *assocreq_ies, *assocresp_ies;
  159. size_t assocreq_ies_len, assocresp_ies_len;
  160. int auth_tries, assoc_tries;
  161. unsigned int ssid_set:1;
  162. unsigned int bssid_set:1;
  163. unsigned int prev_bssid_set:1;
  164. unsigned int authenticated:1;
  165. unsigned int associated:1;
  166. unsigned int probereq_poll:1;
  167. unsigned int use_protection:1;
  168. unsigned int create_ibss:1;
  169. unsigned int mixed_cell:1;
  170. unsigned int wmm_enabled:1;
  171. struct os_time last_probe;
  172. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  173. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  174. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  175. unsigned int auth_algs; /* bitfield of allowed auth algs */
  176. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  177. int auth_transaction;
  178. struct os_time ibss_join_req;
  179. u8 *probe_resp; /* ProbeResp template for IBSS */
  180. size_t probe_resp_len;
  181. u32 supp_rates_bits;
  182. int wmm_last_param_set;
  183. int sta_scanning;
  184. int scan_hw_mode_idx;
  185. int scan_channel_idx;
  186. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  187. struct os_time last_scan_completed;
  188. int scan_oper_channel;
  189. int scan_oper_freq;
  190. int scan_oper_phymode;
  191. u8 scan_ssid[32];
  192. size_t scan_ssid_len;
  193. int scan_skip_11b;
  194. struct ieee80211_sta_bss *sta_bss_list;
  195. #define STA_HASH_SIZE 256
  196. #define STA_HASH(sta) (sta[5])
  197. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  198. int cts_protect_erp_frames;
  199. int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
  200. struct wpa_hw_modes *modes;
  201. size_t num_modes;
  202. unsigned int hw_modes; /* bitfield of allowed hardware modes;
  203. * (1 << MODE_*) */
  204. int num_curr_rates;
  205. struct wpa_rate_data *curr_rates;
  206. int freq; /* The current frequency in MHz */
  207. int channel; /* The current IEEE 802.11 channel number */
  208. #ifdef CONFIG_IEEE80211R
  209. u8 current_md[6];
  210. u8 *ft_ies;
  211. size_t ft_ies_len;
  212. #endif /* CONFIG_IEEE80211R */
  213. #else /* CONFIG_CLIENT_MLME */
  214. int dummy; /* to keep MSVC happy */
  215. #endif /* CONFIG_CLIENT_MLME */
  216. };
  217. /**
  218. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  219. *
  220. * This structure contains the internal data for core wpa_supplicant code. This
  221. * should be only used directly from the core code. However, a pointer to this
  222. * data is used from other files as an arbitrary context pointer in calls to
  223. * core functions.
  224. */
  225. struct wpa_supplicant {
  226. struct wpa_global *global;
  227. struct wpa_supplicant *next;
  228. struct l2_packet_data *l2;
  229. struct l2_packet_data *l2_br;
  230. unsigned char own_addr[ETH_ALEN];
  231. char ifname[100];
  232. #ifdef CONFIG_CTRL_IFACE_DBUS
  233. char *dbus_path;
  234. #endif /* CONFIG_CTRL_IFACE_DBUS */
  235. char bridge_ifname[16];
  236. char *confname;
  237. struct wpa_config *conf;
  238. int countermeasures;
  239. os_time_t last_michael_mic_error;
  240. u8 bssid[ETH_ALEN];
  241. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  242. * field contains the targer BSSID. */
  243. int reassociate; /* reassociation requested */
  244. int disconnected; /* all connections disabled; i.e., do no reassociate
  245. * before this has been cleared */
  246. struct wpa_ssid *current_ssid;
  247. int ap_ies_from_associnfo;
  248. /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
  249. int pairwise_cipher;
  250. int group_cipher;
  251. int key_mgmt;
  252. int mgmt_group_cipher;
  253. void *drv_priv; /* private data used by driver_ops */
  254. struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
  255. * NULL = not yet initialized (start
  256. * with broadcast SSID)
  257. * BROADCAST_SSID_SCAN = broadcast
  258. * SSID was used in the previous scan
  259. */
  260. #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
  261. struct wpa_scan_results *scan_res;
  262. struct wpa_driver_ops *driver;
  263. int interface_removed; /* whether the network interface has been
  264. * removed */
  265. struct wpa_sm *wpa;
  266. struct eapol_sm *eapol;
  267. struct ctrl_iface_priv *ctrl_iface;
  268. wpa_states wpa_state;
  269. int new_connection;
  270. int reassociated_connection;
  271. int eapol_received; /* number of EAPOL packets received after the
  272. * previous association event */
  273. struct scard_data *scard;
  274. unsigned char last_eapol_src[ETH_ALEN];
  275. int keys_cleared;
  276. struct wpa_blacklist *blacklist;
  277. int scan_req; /* manual scan request; this forces a scan even if there
  278. * are no enabled networks in the configuration */
  279. int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
  280. * results without a new scan request; this is used
  281. * to speed up the first association if the driver
  282. * has already available scan results. */
  283. struct wpa_client_mlme mlme;
  284. int use_client_mlme;
  285. int driver_4way_handshake;
  286. };
  287. /* wpa_supplicant.c */
  288. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  289. const char * wpa_supplicant_state_txt(int state);
  290. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  291. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  292. struct wpa_scan_res *bss,
  293. struct wpa_ssid *ssid,
  294. u8 *wpa_ie, size_t *wpa_ie_len);
  295. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  296. struct wpa_scan_res *bss,
  297. struct wpa_ssid *ssid);
  298. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  299. struct wpa_ssid *ssid);
  300. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  301. int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
  302. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  303. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  304. int sec, int usec);
  305. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
  306. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  307. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  308. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  309. int reason_code);
  310. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  311. int reason_code);
  312. void wpa_show_license(void);
  313. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  314. struct wpa_interface *iface);
  315. int wpa_supplicant_remove_iface(struct wpa_global *global,
  316. struct wpa_supplicant *wpa_s);
  317. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  318. const char *ifname);
  319. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  320. int wpa_supplicant_run(struct wpa_global *global);
  321. void wpa_supplicant_deinit(struct wpa_global *global);
  322. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  323. struct wpa_ssid *ssid);
  324. /* scan.c */
  325. void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
  326. void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
  327. /* events.c */
  328. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  329. /* driver_ops */
  330. static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
  331. const char *ifname)
  332. {
  333. if (wpa_s->driver->init) {
  334. return wpa_s->driver->init(wpa_s, ifname);
  335. }
  336. return NULL;
  337. }
  338. static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
  339. {
  340. if (wpa_s->driver->deinit)
  341. wpa_s->driver->deinit(wpa_s->drv_priv);
  342. }
  343. static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
  344. const char *param)
  345. {
  346. if (wpa_s->driver->set_param)
  347. return wpa_s->driver->set_param(wpa_s->drv_priv, param);
  348. return 0;
  349. }
  350. static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
  351. int enabled)
  352. {
  353. if (wpa_s->driver->set_drop_unencrypted) {
  354. return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
  355. enabled);
  356. }
  357. return -1;
  358. }
  359. static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
  360. int enabled)
  361. {
  362. if (wpa_s->driver->set_countermeasures) {
  363. return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
  364. enabled);
  365. }
  366. return -1;
  367. }
  368. static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
  369. int auth_alg)
  370. {
  371. if (wpa_s->driver->set_auth_alg) {
  372. return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
  373. auth_alg);
  374. }
  375. return -1;
  376. }
  377. static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
  378. {
  379. if (wpa_s->driver->set_wpa) {
  380. return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
  381. }
  382. return 0;
  383. }
  384. static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
  385. struct wpa_driver_associate_params *params)
  386. {
  387. if (wpa_s->driver->associate) {
  388. return wpa_s->driver->associate(wpa_s->drv_priv, params);
  389. }
  390. return -1;
  391. }
  392. static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
  393. size_t ssid_len)
  394. {
  395. if (wpa_s->driver->scan) {
  396. return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
  397. }
  398. return -1;
  399. }
  400. static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
  401. struct wpa_scan_result *results,
  402. size_t max_size)
  403. {
  404. if (wpa_s->driver->get_scan_results) {
  405. return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
  406. results, max_size);
  407. }
  408. return -1;
  409. }
  410. static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
  411. struct wpa_supplicant *wpa_s)
  412. {
  413. if (wpa_s->driver->get_scan_results2)
  414. return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
  415. return NULL;
  416. }
  417. static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
  418. {
  419. if (wpa_s->driver->get_bssid) {
  420. return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
  421. }
  422. return -1;
  423. }
  424. static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
  425. {
  426. if (wpa_s->driver->get_ssid) {
  427. return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
  428. }
  429. return -1;
  430. }
  431. static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
  432. const u8 *addr, int key_idx, int set_tx,
  433. const u8 *seq, size_t seq_len,
  434. const u8 *key, size_t key_len)
  435. {
  436. if (wpa_s->driver->set_key) {
  437. wpa_s->keys_cleared = 0;
  438. return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
  439. key_idx, set_tx, seq, seq_len,
  440. key, key_len);
  441. }
  442. return -1;
  443. }
  444. static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
  445. const u8 *addr, int reason_code)
  446. {
  447. if (wpa_s->driver->deauthenticate) {
  448. return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
  449. reason_code);
  450. }
  451. return -1;
  452. }
  453. static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
  454. const u8 *addr, int reason_code)
  455. {
  456. if (wpa_s->driver->disassociate) {
  457. return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
  458. reason_code);
  459. }
  460. return -1;
  461. }
  462. static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
  463. const u8 *bssid, const u8 *pmkid)
  464. {
  465. if (wpa_s->driver->add_pmkid) {
  466. return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
  467. }
  468. return -1;
  469. }
  470. static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
  471. const u8 *bssid, const u8 *pmkid)
  472. {
  473. if (wpa_s->driver->remove_pmkid) {
  474. return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
  475. pmkid);
  476. }
  477. return -1;
  478. }
  479. static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
  480. {
  481. if (wpa_s->driver->flush_pmkid) {
  482. return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
  483. }
  484. return -1;
  485. }
  486. static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
  487. struct wpa_driver_capa *capa)
  488. {
  489. if (wpa_s->driver->get_capa) {
  490. return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
  491. }
  492. return -1;
  493. }
  494. static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
  495. {
  496. if (wpa_s->driver->poll) {
  497. wpa_s->driver->poll(wpa_s->drv_priv);
  498. }
  499. }
  500. static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
  501. {
  502. if (wpa_s->driver->get_ifname) {
  503. return wpa_s->driver->get_ifname(wpa_s->drv_priv);
  504. }
  505. return NULL;
  506. }
  507. static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
  508. {
  509. if (wpa_s->driver->get_mac_addr) {
  510. return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
  511. }
  512. return NULL;
  513. }
  514. static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
  515. const u8 *dst, u16 proto,
  516. const u8 *data, size_t data_len)
  517. {
  518. if (wpa_s->driver->send_eapol)
  519. return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
  520. data, data_len);
  521. return -1;
  522. }
  523. static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
  524. int state)
  525. {
  526. if (wpa_s->driver->set_operstate)
  527. return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
  528. return 0;
  529. }
  530. static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
  531. const u8 *addr, int protect_type,
  532. int key_type)
  533. {
  534. if (wpa_s->driver->mlme_setprotection)
  535. return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
  536. protect_type,
  537. key_type);
  538. return 0;
  539. }
  540. static inline struct wpa_hw_modes *
  541. wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
  542. u16 *flags)
  543. {
  544. if (wpa_s->driver->get_hw_feature_data)
  545. return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
  546. num_modes, flags);
  547. return NULL;
  548. }
  549. static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
  550. wpa_hw_mode phymode, int chan,
  551. int freq)
  552. {
  553. if (wpa_s->driver->set_channel)
  554. return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
  555. chan, freq);
  556. return -1;
  557. }
  558. static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
  559. const u8 *ssid, size_t ssid_len)
  560. {
  561. if (wpa_s->driver->set_ssid) {
  562. return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
  563. ssid_len);
  564. }
  565. return -1;
  566. }
  567. static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
  568. const u8 *bssid)
  569. {
  570. if (wpa_s->driver->set_bssid) {
  571. return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
  572. }
  573. return -1;
  574. }
  575. static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
  576. const u8 *data, size_t data_len)
  577. {
  578. if (wpa_s->driver->send_mlme)
  579. return wpa_s->driver->send_mlme(wpa_s->drv_priv,
  580. data, data_len);
  581. return -1;
  582. }
  583. static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
  584. const u8 *addr, const u8 *supp_rates,
  585. size_t supp_rates_len)
  586. {
  587. if (wpa_s->driver->mlme_add_sta)
  588. return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
  589. supp_rates, supp_rates_len);
  590. return -1;
  591. }
  592. static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
  593. const u8 *addr)
  594. {
  595. if (wpa_s->driver->mlme_remove_sta)
  596. return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
  597. return -1;
  598. }
  599. static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
  600. const u8 *md,
  601. const u8 *ies, size_t ies_len)
  602. {
  603. if (wpa_s->driver->update_ft_ies)
  604. return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
  605. ies, ies_len);
  606. return -1;
  607. }
  608. static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
  609. u8 action, const u8 *target_ap,
  610. const u8 *ies, size_t ies_len)
  611. {
  612. if (wpa_s->driver->send_ft_action)
  613. return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
  614. target_ap, ies, ies_len);
  615. return -1;
  616. }
  617. static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
  618. const u8 *ies, size_t ies_len)
  619. {
  620. if (wpa_s->driver->set_probe_req_ie)
  621. return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
  622. ies_len);
  623. return -1;
  624. }
  625. #endif /* WPA_SUPPLICANT_I_H */