wpa_supplicant_i.h 21 KB

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