wpa_supplicant_i.h 20 KB

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