wpa_supplicant_i.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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. void **drv_priv;
  140. size_t drv_count;
  141. };
  142. struct wpa_client_mlme {
  143. #ifdef CONFIG_CLIENT_MLME
  144. enum {
  145. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  146. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  147. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
  148. } state;
  149. u8 prev_bssid[ETH_ALEN];
  150. u8 ssid[32];
  151. size_t ssid_len;
  152. u16 aid;
  153. u16 ap_capab, capab;
  154. u8 *extra_ie; /* to be added to the end of AssocReq */
  155. size_t extra_ie_len;
  156. u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
  157. size_t extra_probe_ie_len;
  158. wpa_key_mgmt key_mgmt;
  159. /* The last AssocReq/Resp IEs */
  160. u8 *assocreq_ies, *assocresp_ies;
  161. size_t assocreq_ies_len, assocresp_ies_len;
  162. int auth_tries, assoc_tries;
  163. unsigned int ssid_set:1;
  164. unsigned int bssid_set:1;
  165. unsigned int prev_bssid_set:1;
  166. unsigned int authenticated:1;
  167. unsigned int associated:1;
  168. unsigned int probereq_poll:1;
  169. unsigned int use_protection:1;
  170. unsigned int create_ibss:1;
  171. unsigned int mixed_cell:1;
  172. unsigned int wmm_enabled:1;
  173. struct os_time last_probe;
  174. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  175. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  176. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  177. unsigned int auth_algs; /* bitfield of allowed auth algs */
  178. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  179. int auth_transaction;
  180. struct os_time ibss_join_req;
  181. u8 *probe_resp; /* ProbeResp template for IBSS */
  182. size_t probe_resp_len;
  183. u32 supp_rates_bits;
  184. int wmm_last_param_set;
  185. int sta_scanning;
  186. int scan_hw_mode_idx;
  187. int scan_channel_idx;
  188. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  189. struct os_time last_scan_completed;
  190. int scan_oper_channel;
  191. int scan_oper_freq;
  192. int scan_oper_phymode;
  193. u8 scan_ssid[32];
  194. size_t scan_ssid_len;
  195. int scan_skip_11b;
  196. struct ieee80211_sta_bss *sta_bss_list;
  197. #define STA_HASH_SIZE 256
  198. #define STA_HASH(sta) (sta[5])
  199. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  200. int cts_protect_erp_frames;
  201. int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
  202. struct wpa_hw_modes *modes;
  203. size_t num_modes;
  204. unsigned int hw_modes; /* bitfield of allowed hardware modes;
  205. * (1 << MODE_*) */
  206. int num_curr_rates;
  207. struct wpa_rate_data *curr_rates;
  208. int freq; /* The current frequency in MHz */
  209. int channel; /* The current IEEE 802.11 channel number */
  210. #ifdef CONFIG_IEEE80211R
  211. u8 current_md[6];
  212. u8 *ft_ies;
  213. size_t ft_ies_len;
  214. #endif /* CONFIG_IEEE80211R */
  215. #else /* CONFIG_CLIENT_MLME */
  216. int dummy; /* to keep MSVC happy */
  217. #endif /* CONFIG_CLIENT_MLME */
  218. };
  219. /**
  220. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  221. *
  222. * This structure contains the internal data for core wpa_supplicant code. This
  223. * should be only used directly from the core code. However, a pointer to this
  224. * data is used from other files as an arbitrary context pointer in calls to
  225. * core functions.
  226. */
  227. struct wpa_supplicant {
  228. struct wpa_global *global;
  229. struct wpa_supplicant *next;
  230. struct l2_packet_data *l2;
  231. struct l2_packet_data *l2_br;
  232. unsigned char own_addr[ETH_ALEN];
  233. char ifname[100];
  234. #ifdef CONFIG_CTRL_IFACE_DBUS
  235. char *dbus_path;
  236. #endif /* CONFIG_CTRL_IFACE_DBUS */
  237. char bridge_ifname[16];
  238. char *confname;
  239. struct wpa_config *conf;
  240. int countermeasures;
  241. os_time_t last_michael_mic_error;
  242. u8 bssid[ETH_ALEN];
  243. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  244. * field contains the targer BSSID. */
  245. int reassociate; /* reassociation requested */
  246. int disconnected; /* all connections disabled; i.e., do no reassociate
  247. * before this has been cleared */
  248. struct wpa_ssid *current_ssid;
  249. int ap_ies_from_associnfo;
  250. /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
  251. int pairwise_cipher;
  252. int group_cipher;
  253. int key_mgmt;
  254. int mgmt_group_cipher;
  255. void *drv_priv; /* private data used by driver_ops */
  256. struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
  257. * NULL = not yet initialized (start
  258. * with broadcast SSID)
  259. * BROADCAST_SSID_SCAN = broadcast
  260. * SSID was used in the previous scan
  261. */
  262. #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
  263. struct wpa_scan_results *scan_res;
  264. struct wpa_driver_ops *driver;
  265. int interface_removed; /* whether the network interface has been
  266. * removed */
  267. struct wpa_sm *wpa;
  268. struct eapol_sm *eapol;
  269. struct ctrl_iface_priv *ctrl_iface;
  270. wpa_states wpa_state;
  271. int new_connection;
  272. int reassociated_connection;
  273. int eapol_received; /* number of EAPOL packets received after the
  274. * previous association event */
  275. struct scard_data *scard;
  276. unsigned char last_eapol_src[ETH_ALEN];
  277. int keys_cleared;
  278. struct wpa_blacklist *blacklist;
  279. int scan_req; /* manual scan request; this forces a scan even if there
  280. * are no enabled networks in the configuration */
  281. int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
  282. * results without a new scan request; this is used
  283. * to speed up the first association if the driver
  284. * has already available scan results. */
  285. struct wpa_client_mlme mlme;
  286. int use_client_mlme;
  287. int driver_4way_handshake;
  288. int pending_mic_error_report;
  289. int pending_mic_error_pairwise;
  290. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  291. struct wps_context *wps;
  292. };
  293. /* wpa_supplicant.c */
  294. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  295. const char * wpa_supplicant_state_txt(int state);
  296. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  297. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  298. struct wpa_scan_res *bss,
  299. struct wpa_ssid *ssid,
  300. u8 *wpa_ie, size_t *wpa_ie_len);
  301. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  302. struct wpa_scan_res *bss,
  303. struct wpa_ssid *ssid);
  304. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  305. struct wpa_ssid *ssid);
  306. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  307. int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
  308. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  309. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  310. int sec, int usec);
  311. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
  312. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  313. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  314. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  315. int reason_code);
  316. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  317. int reason_code);
  318. void wpa_show_license(void);
  319. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  320. struct wpa_interface *iface);
  321. int wpa_supplicant_remove_iface(struct wpa_global *global,
  322. struct wpa_supplicant *wpa_s);
  323. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  324. const char *ifname);
  325. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  326. int wpa_supplicant_run(struct wpa_global *global);
  327. void wpa_supplicant_deinit(struct wpa_global *global);
  328. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  329. struct wpa_ssid *ssid);
  330. /* scan.c */
  331. void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
  332. void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
  333. /* events.c */
  334. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  335. /* driver_ops */
  336. static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
  337. const char *ifname)
  338. {
  339. if (wpa_s->driver->init2)
  340. return wpa_s->driver->init2(wpa_s, ifname, wpa_s->global);
  341. if (wpa_s->driver->init) {
  342. return wpa_s->driver->init(wpa_s, ifname);
  343. }
  344. return NULL;
  345. }
  346. static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
  347. {
  348. if (wpa_s->driver->deinit)
  349. wpa_s->driver->deinit(wpa_s->drv_priv);
  350. }
  351. static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
  352. const char *param)
  353. {
  354. if (wpa_s->driver->set_param)
  355. return wpa_s->driver->set_param(wpa_s->drv_priv, param);
  356. return 0;
  357. }
  358. static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
  359. int enabled)
  360. {
  361. if (wpa_s->driver->set_drop_unencrypted) {
  362. return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
  363. enabled);
  364. }
  365. return -1;
  366. }
  367. static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
  368. int enabled)
  369. {
  370. if (wpa_s->driver->set_countermeasures) {
  371. return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
  372. enabled);
  373. }
  374. return -1;
  375. }
  376. static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
  377. int auth_alg)
  378. {
  379. if (wpa_s->driver->set_auth_alg) {
  380. return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
  381. auth_alg);
  382. }
  383. return -1;
  384. }
  385. static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
  386. {
  387. if (wpa_s->driver->set_wpa) {
  388. return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
  389. }
  390. return 0;
  391. }
  392. static inline int wpa_drv_set_mode(struct wpa_supplicant *wpa_s, int mode)
  393. {
  394. if (wpa_s->driver->set_mode) {
  395. return wpa_s->driver->set_mode(wpa_s->drv_priv, mode);
  396. }
  397. return 0;
  398. }
  399. static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
  400. struct wpa_driver_associate_params *params)
  401. {
  402. if (wpa_s->driver->associate) {
  403. return wpa_s->driver->associate(wpa_s->drv_priv, params);
  404. }
  405. return -1;
  406. }
  407. static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
  408. size_t ssid_len)
  409. {
  410. if (wpa_s->driver->scan) {
  411. return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
  412. }
  413. return -1;
  414. }
  415. static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
  416. struct wpa_scan_result *results,
  417. size_t max_size)
  418. {
  419. if (wpa_s->driver->get_scan_results) {
  420. return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
  421. results, max_size);
  422. }
  423. return -1;
  424. }
  425. static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
  426. struct wpa_supplicant *wpa_s)
  427. {
  428. if (wpa_s->driver->get_scan_results2)
  429. return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
  430. return NULL;
  431. }
  432. static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
  433. {
  434. if (wpa_s->driver->get_bssid) {
  435. return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
  436. }
  437. return -1;
  438. }
  439. static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
  440. {
  441. if (wpa_s->driver->get_ssid) {
  442. return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
  443. }
  444. return -1;
  445. }
  446. static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
  447. const u8 *addr, int key_idx, int set_tx,
  448. const u8 *seq, size_t seq_len,
  449. const u8 *key, size_t key_len)
  450. {
  451. if (wpa_s->driver->set_key) {
  452. wpa_s->keys_cleared = 0;
  453. return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
  454. key_idx, set_tx, seq, seq_len,
  455. key, key_len);
  456. }
  457. return -1;
  458. }
  459. static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
  460. const u8 *addr, int reason_code)
  461. {
  462. if (wpa_s->driver->deauthenticate) {
  463. return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
  464. reason_code);
  465. }
  466. return -1;
  467. }
  468. static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
  469. const u8 *addr, int reason_code)
  470. {
  471. if (wpa_s->driver->disassociate) {
  472. return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
  473. reason_code);
  474. }
  475. return -1;
  476. }
  477. static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
  478. const u8 *bssid, const u8 *pmkid)
  479. {
  480. if (wpa_s->driver->add_pmkid) {
  481. return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
  482. }
  483. return -1;
  484. }
  485. static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
  486. const u8 *bssid, const u8 *pmkid)
  487. {
  488. if (wpa_s->driver->remove_pmkid) {
  489. return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
  490. pmkid);
  491. }
  492. return -1;
  493. }
  494. static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
  495. {
  496. if (wpa_s->driver->flush_pmkid) {
  497. return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
  498. }
  499. return -1;
  500. }
  501. static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
  502. struct wpa_driver_capa *capa)
  503. {
  504. if (wpa_s->driver->get_capa) {
  505. return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
  506. }
  507. return -1;
  508. }
  509. static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
  510. {
  511. if (wpa_s->driver->poll) {
  512. wpa_s->driver->poll(wpa_s->drv_priv);
  513. }
  514. }
  515. static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
  516. {
  517. if (wpa_s->driver->get_ifname) {
  518. return wpa_s->driver->get_ifname(wpa_s->drv_priv);
  519. }
  520. return NULL;
  521. }
  522. static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
  523. {
  524. if (wpa_s->driver->get_mac_addr) {
  525. return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
  526. }
  527. return NULL;
  528. }
  529. static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
  530. const u8 *dst, u16 proto,
  531. const u8 *data, size_t data_len)
  532. {
  533. if (wpa_s->driver->send_eapol)
  534. return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
  535. data, data_len);
  536. return -1;
  537. }
  538. static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
  539. int state)
  540. {
  541. if (wpa_s->driver->set_operstate)
  542. return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
  543. return 0;
  544. }
  545. static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
  546. const u8 *addr, int protect_type,
  547. int key_type)
  548. {
  549. if (wpa_s->driver->mlme_setprotection)
  550. return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
  551. protect_type,
  552. key_type);
  553. return 0;
  554. }
  555. static inline struct wpa_hw_modes *
  556. wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
  557. u16 *flags)
  558. {
  559. if (wpa_s->driver->get_hw_feature_data)
  560. return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
  561. num_modes, flags);
  562. return NULL;
  563. }
  564. static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
  565. wpa_hw_mode phymode, int chan,
  566. int freq)
  567. {
  568. if (wpa_s->driver->set_channel)
  569. return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
  570. chan, freq);
  571. return -1;
  572. }
  573. static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
  574. const u8 *ssid, size_t ssid_len)
  575. {
  576. if (wpa_s->driver->set_ssid) {
  577. return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
  578. ssid_len);
  579. }
  580. return -1;
  581. }
  582. static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
  583. const u8 *bssid)
  584. {
  585. if (wpa_s->driver->set_bssid) {
  586. return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
  587. }
  588. return -1;
  589. }
  590. static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
  591. const char *alpha2)
  592. {
  593. if (wpa_s->driver->set_country)
  594. return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
  595. return 0;
  596. }
  597. static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
  598. const u8 *data, size_t data_len)
  599. {
  600. if (wpa_s->driver->send_mlme)
  601. return wpa_s->driver->send_mlme(wpa_s->drv_priv,
  602. data, data_len);
  603. return -1;
  604. }
  605. static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
  606. const u8 *addr, const u8 *supp_rates,
  607. size_t supp_rates_len)
  608. {
  609. if (wpa_s->driver->mlme_add_sta)
  610. return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
  611. supp_rates, supp_rates_len);
  612. return -1;
  613. }
  614. static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
  615. const u8 *addr)
  616. {
  617. if (wpa_s->driver->mlme_remove_sta)
  618. return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
  619. return -1;
  620. }
  621. static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
  622. const u8 *md,
  623. const u8 *ies, size_t ies_len)
  624. {
  625. if (wpa_s->driver->update_ft_ies)
  626. return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
  627. ies, ies_len);
  628. return -1;
  629. }
  630. static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
  631. u8 action, const u8 *target_ap,
  632. const u8 *ies, size_t ies_len)
  633. {
  634. if (wpa_s->driver->send_ft_action)
  635. return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
  636. target_ap, ies, ies_len);
  637. return -1;
  638. }
  639. static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
  640. const u8 *ies, size_t ies_len)
  641. {
  642. if (wpa_s->driver->set_probe_req_ie)
  643. return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
  644. ies_len);
  645. return -1;
  646. }
  647. #endif /* WPA_SUPPLICANT_I_H */