wpa_supplicant_i.h 20 KB

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