wpa_supplicant_i.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  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. int pending_mic_error_report;
  287. int pending_mic_error_pairwise;
  288. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  289. };
  290. /* wpa_supplicant.c */
  291. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  292. const char * wpa_supplicant_state_txt(int state);
  293. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  294. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  295. struct wpa_scan_res *bss,
  296. struct wpa_ssid *ssid,
  297. u8 *wpa_ie, size_t *wpa_ie_len);
  298. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  299. struct wpa_scan_res *bss,
  300. struct wpa_ssid *ssid);
  301. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  302. struct wpa_ssid *ssid);
  303. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  304. int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
  305. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  306. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  307. int sec, int usec);
  308. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
  309. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  310. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  311. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  312. int reason_code);
  313. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  314. int reason_code);
  315. void wpa_show_license(void);
  316. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  317. struct wpa_interface *iface);
  318. int wpa_supplicant_remove_iface(struct wpa_global *global,
  319. struct wpa_supplicant *wpa_s);
  320. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  321. const char *ifname);
  322. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  323. int wpa_supplicant_run(struct wpa_global *global);
  324. void wpa_supplicant_deinit(struct wpa_global *global);
  325. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  326. struct wpa_ssid *ssid);
  327. /* scan.c */
  328. void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
  329. void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
  330. /* events.c */
  331. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  332. /* driver_ops */
  333. static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
  334. const char *ifname)
  335. {
  336. if (wpa_s->driver->init) {
  337. return wpa_s->driver->init(wpa_s, ifname);
  338. }
  339. return NULL;
  340. }
  341. static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
  342. {
  343. if (wpa_s->driver->deinit)
  344. wpa_s->driver->deinit(wpa_s->drv_priv);
  345. }
  346. static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
  347. const char *param)
  348. {
  349. if (wpa_s->driver->set_param)
  350. return wpa_s->driver->set_param(wpa_s->drv_priv, param);
  351. return 0;
  352. }
  353. static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
  354. int enabled)
  355. {
  356. if (wpa_s->driver->set_drop_unencrypted) {
  357. return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
  358. enabled);
  359. }
  360. return -1;
  361. }
  362. static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
  363. int enabled)
  364. {
  365. if (wpa_s->driver->set_countermeasures) {
  366. return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
  367. enabled);
  368. }
  369. return -1;
  370. }
  371. static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
  372. int auth_alg)
  373. {
  374. if (wpa_s->driver->set_auth_alg) {
  375. return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
  376. auth_alg);
  377. }
  378. return -1;
  379. }
  380. static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
  381. {
  382. if (wpa_s->driver->set_wpa) {
  383. return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
  384. }
  385. return 0;
  386. }
  387. static inline int wpa_drv_set_mode(struct wpa_supplicant *wpa_s, int mode)
  388. {
  389. if (wpa_s->driver->set_mode) {
  390. return wpa_s->driver->set_mode(wpa_s->drv_priv, mode);
  391. }
  392. return 0;
  393. }
  394. static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
  395. struct wpa_driver_associate_params *params)
  396. {
  397. if (wpa_s->driver->associate) {
  398. return wpa_s->driver->associate(wpa_s->drv_priv, params);
  399. }
  400. return -1;
  401. }
  402. static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
  403. size_t ssid_len)
  404. {
  405. if (wpa_s->driver->scan) {
  406. return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
  407. }
  408. return -1;
  409. }
  410. static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
  411. struct wpa_scan_result *results,
  412. size_t max_size)
  413. {
  414. if (wpa_s->driver->get_scan_results) {
  415. return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
  416. results, max_size);
  417. }
  418. return -1;
  419. }
  420. static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
  421. struct wpa_supplicant *wpa_s)
  422. {
  423. if (wpa_s->driver->get_scan_results2)
  424. return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
  425. return NULL;
  426. }
  427. static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
  428. {
  429. if (wpa_s->driver->get_bssid) {
  430. return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
  431. }
  432. return -1;
  433. }
  434. static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
  435. {
  436. if (wpa_s->driver->get_ssid) {
  437. return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
  438. }
  439. return -1;
  440. }
  441. static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
  442. const u8 *addr, int key_idx, int set_tx,
  443. const u8 *seq, size_t seq_len,
  444. const u8 *key, size_t key_len)
  445. {
  446. if (wpa_s->driver->set_key) {
  447. wpa_s->keys_cleared = 0;
  448. return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
  449. key_idx, set_tx, seq, seq_len,
  450. key, key_len);
  451. }
  452. return -1;
  453. }
  454. static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
  455. const u8 *addr, int reason_code)
  456. {
  457. if (wpa_s->driver->deauthenticate) {
  458. return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
  459. reason_code);
  460. }
  461. return -1;
  462. }
  463. static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
  464. const u8 *addr, int reason_code)
  465. {
  466. if (wpa_s->driver->disassociate) {
  467. return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
  468. reason_code);
  469. }
  470. return -1;
  471. }
  472. static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
  473. const u8 *bssid, const u8 *pmkid)
  474. {
  475. if (wpa_s->driver->add_pmkid) {
  476. return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
  477. }
  478. return -1;
  479. }
  480. static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
  481. const u8 *bssid, const u8 *pmkid)
  482. {
  483. if (wpa_s->driver->remove_pmkid) {
  484. return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
  485. pmkid);
  486. }
  487. return -1;
  488. }
  489. static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
  490. {
  491. if (wpa_s->driver->flush_pmkid) {
  492. return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
  493. }
  494. return -1;
  495. }
  496. static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
  497. struct wpa_driver_capa *capa)
  498. {
  499. if (wpa_s->driver->get_capa) {
  500. return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
  501. }
  502. return -1;
  503. }
  504. static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
  505. {
  506. if (wpa_s->driver->poll) {
  507. wpa_s->driver->poll(wpa_s->drv_priv);
  508. }
  509. }
  510. static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
  511. {
  512. if (wpa_s->driver->get_ifname) {
  513. return wpa_s->driver->get_ifname(wpa_s->drv_priv);
  514. }
  515. return NULL;
  516. }
  517. static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
  518. {
  519. if (wpa_s->driver->get_mac_addr) {
  520. return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
  521. }
  522. return NULL;
  523. }
  524. static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
  525. const u8 *dst, u16 proto,
  526. const u8 *data, size_t data_len)
  527. {
  528. if (wpa_s->driver->send_eapol)
  529. return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
  530. data, data_len);
  531. return -1;
  532. }
  533. static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
  534. int state)
  535. {
  536. if (wpa_s->driver->set_operstate)
  537. return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
  538. return 0;
  539. }
  540. static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
  541. const u8 *addr, int protect_type,
  542. int key_type)
  543. {
  544. if (wpa_s->driver->mlme_setprotection)
  545. return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
  546. protect_type,
  547. key_type);
  548. return 0;
  549. }
  550. static inline struct wpa_hw_modes *
  551. wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
  552. u16 *flags)
  553. {
  554. if (wpa_s->driver->get_hw_feature_data)
  555. return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
  556. num_modes, flags);
  557. return NULL;
  558. }
  559. static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
  560. wpa_hw_mode phymode, int chan,
  561. int freq)
  562. {
  563. if (wpa_s->driver->set_channel)
  564. return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
  565. chan, freq);
  566. return -1;
  567. }
  568. static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
  569. const u8 *ssid, size_t ssid_len)
  570. {
  571. if (wpa_s->driver->set_ssid) {
  572. return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
  573. ssid_len);
  574. }
  575. return -1;
  576. }
  577. static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
  578. const u8 *bssid)
  579. {
  580. if (wpa_s->driver->set_bssid) {
  581. return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
  582. }
  583. return -1;
  584. }
  585. static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
  586. const u8 *data, size_t data_len)
  587. {
  588. if (wpa_s->driver->send_mlme)
  589. return wpa_s->driver->send_mlme(wpa_s->drv_priv,
  590. data, data_len);
  591. return -1;
  592. }
  593. static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
  594. const u8 *addr, const u8 *supp_rates,
  595. size_t supp_rates_len)
  596. {
  597. if (wpa_s->driver->mlme_add_sta)
  598. return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
  599. supp_rates, supp_rates_len);
  600. return -1;
  601. }
  602. static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
  603. const u8 *addr)
  604. {
  605. if (wpa_s->driver->mlme_remove_sta)
  606. return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
  607. return -1;
  608. }
  609. static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
  610. const u8 *md,
  611. const u8 *ies, size_t ies_len)
  612. {
  613. if (wpa_s->driver->update_ft_ies)
  614. return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
  615. ies, ies_len);
  616. return -1;
  617. }
  618. static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
  619. u8 action, const u8 *target_ap,
  620. const u8 *ies, size_t ies_len)
  621. {
  622. if (wpa_s->driver->send_ft_action)
  623. return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
  624. target_ap, ies, ies_len);
  625. return -1;
  626. }
  627. static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
  628. const u8 *ies, size_t ies_len)
  629. {
  630. if (wpa_s->driver->set_probe_req_ie)
  631. return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
  632. ies_len);
  633. return -1;
  634. }
  635. #endif /* WPA_SUPPLICANT_I_H */