wpa_supplicant_i.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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 "common/defs.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. struct wpa_scan_result;
  27. struct wpa_scan_res;
  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. * wpa_debug_syslog - Enable log output through syslog
  140. */
  141. int wpa_debug_syslog;
  142. /**
  143. * override_driver - Optional driver parameter override
  144. *
  145. * This parameter can be used to override the driver parameter in
  146. * dynamic interface addition to force a specific driver wrapper to be
  147. * used instead.
  148. */
  149. char *override_driver;
  150. /**
  151. * override_ctrl_interface - Optional ctrl_interface override
  152. *
  153. * This parameter can be used to override the ctrl_interface parameter
  154. * in dynamic interface addition to force a control interface to be
  155. * created.
  156. */
  157. char *override_ctrl_interface;
  158. };
  159. /**
  160. * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
  161. *
  162. * This structure is initialized by calling wpa_supplicant_init() when starting
  163. * %wpa_supplicant.
  164. */
  165. struct wpa_global {
  166. struct wpa_supplicant *ifaces;
  167. struct wpa_params params;
  168. struct ctrl_iface_global_priv *ctrl_iface;
  169. /* old DBus API data */
  170. struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
  171. /* new DBus API data */
  172. struct ctrl_iface_dbus_new_priv *dbus_new_ctrl_iface;
  173. void **drv_priv;
  174. size_t drv_count;
  175. };
  176. struct wpa_client_mlme {
  177. #ifdef CONFIG_CLIENT_MLME
  178. enum {
  179. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  180. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  181. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
  182. } state;
  183. u8 prev_bssid[ETH_ALEN];
  184. u8 ssid[32];
  185. size_t ssid_len;
  186. u16 aid;
  187. u16 ap_capab, capab;
  188. u8 *extra_ie; /* to be added to the end of AssocReq */
  189. size_t extra_ie_len;
  190. u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
  191. size_t extra_probe_ie_len;
  192. wpa_key_mgmt key_mgmt;
  193. /* The last AssocReq/Resp IEs */
  194. u8 *assocreq_ies, *assocresp_ies;
  195. size_t assocreq_ies_len, assocresp_ies_len;
  196. int auth_tries, assoc_tries;
  197. unsigned int ssid_set:1;
  198. unsigned int bssid_set:1;
  199. unsigned int prev_bssid_set:1;
  200. unsigned int authenticated:1;
  201. unsigned int associated:1;
  202. unsigned int probereq_poll:1;
  203. unsigned int use_protection:1;
  204. unsigned int create_ibss:1;
  205. unsigned int mixed_cell:1;
  206. unsigned int wmm_enabled:1;
  207. struct os_time last_probe;
  208. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  209. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  210. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  211. unsigned int auth_algs; /* bitfield of allowed auth algs */
  212. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  213. int auth_transaction;
  214. struct os_time ibss_join_req;
  215. u8 *probe_resp; /* ProbeResp template for IBSS */
  216. size_t probe_resp_len;
  217. u32 supp_rates_bits;
  218. int wmm_last_param_set;
  219. int sta_scanning;
  220. int scan_hw_mode_idx;
  221. int scan_channel_idx;
  222. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  223. struct os_time last_scan_completed;
  224. int scan_oper_channel;
  225. int scan_oper_freq;
  226. int scan_oper_phymode;
  227. u8 scan_ssid[32];
  228. size_t scan_ssid_len;
  229. int scan_skip_11b;
  230. struct ieee80211_sta_bss *sta_bss_list;
  231. #define STA_HASH_SIZE 256
  232. #define STA_HASH(sta) (sta[5])
  233. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  234. int cts_protect_erp_frames;
  235. hostapd_hw_mode phymode; /* current mode */
  236. struct hostapd_hw_modes *modes;
  237. size_t num_modes;
  238. unsigned int hw_modes; /* bitfield of allowed hardware modes;
  239. * (1 << HOSTAPD_MODE_*) */
  240. int num_curr_rates;
  241. struct hostapd_rate_data *curr_rates;
  242. int freq; /* The current frequency in MHz */
  243. int channel; /* The current IEEE 802.11 channel number */
  244. #ifdef CONFIG_IEEE80211R
  245. u8 current_md[6];
  246. u8 *ft_ies;
  247. size_t ft_ies_len;
  248. #endif /* CONFIG_IEEE80211R */
  249. #else /* CONFIG_CLIENT_MLME */
  250. int dummy; /* to keep MSVC happy */
  251. #endif /* CONFIG_CLIENT_MLME */
  252. };
  253. /**
  254. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  255. *
  256. * This structure contains the internal data for core wpa_supplicant code. This
  257. * should be only used directly from the core code. However, a pointer to this
  258. * data is used from other files as an arbitrary context pointer in calls to
  259. * core functions.
  260. */
  261. struct wpa_supplicant {
  262. struct wpa_global *global;
  263. struct wpa_supplicant *next;
  264. struct l2_packet_data *l2;
  265. struct l2_packet_data *l2_br;
  266. unsigned char own_addr[ETH_ALEN];
  267. char ifname[100];
  268. #ifdef CONFIG_CTRL_IFACE_DBUS
  269. char *dbus_path;
  270. #endif /* CONFIG_CTRL_IFACE_DBUS */
  271. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  272. char *dbus_new_path;
  273. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  274. char bridge_ifname[16];
  275. char *confname;
  276. struct wpa_config *conf;
  277. int countermeasures;
  278. os_time_t last_michael_mic_error;
  279. u8 bssid[ETH_ALEN];
  280. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  281. * field contains the targer BSSID. */
  282. int reassociate; /* reassociation requested */
  283. int disconnected; /* all connections disabled; i.e., do no reassociate
  284. * before this has been cleared */
  285. struct wpa_ssid *current_ssid;
  286. int ap_ies_from_associnfo;
  287. /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
  288. int pairwise_cipher;
  289. int group_cipher;
  290. int key_mgmt;
  291. int mgmt_group_cipher;
  292. void *drv_priv; /* private data used by driver_ops */
  293. void *global_drv_priv;
  294. struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
  295. * NULL = not yet initialized (start
  296. * with wildcard SSID)
  297. * WILDCARD_SSID_SCAN = wildcard
  298. * SSID was used in the previous scan
  299. */
  300. #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
  301. struct wpa_scan_results *scan_res;
  302. struct wpa_driver_ops *driver;
  303. int interface_removed; /* whether the network interface has been
  304. * removed */
  305. struct wpa_sm *wpa;
  306. struct eapol_sm *eapol;
  307. struct ctrl_iface_priv *ctrl_iface;
  308. wpa_states wpa_state;
  309. int scanning;
  310. int new_connection;
  311. int reassociated_connection;
  312. int eapol_received; /* number of EAPOL packets received after the
  313. * previous association event */
  314. struct scard_data *scard;
  315. unsigned char last_eapol_src[ETH_ALEN];
  316. int keys_cleared;
  317. struct wpa_blacklist *blacklist;
  318. int scan_req; /* manual scan request; this forces a scan even if there
  319. * are no enabled networks in the configuration */
  320. int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
  321. * results without a new scan request; this is used
  322. * to speed up the first association if the driver
  323. * has already available scan results. */
  324. int scan_runs; /* number of scan runs since WPS was started */
  325. struct wpa_client_mlme mlme;
  326. unsigned int drv_flags;
  327. int max_scan_ssids;
  328. int pending_mic_error_report;
  329. int pending_mic_error_pairwise;
  330. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  331. struct wps_context *wps;
  332. int wps_success; /* WPS success event received */
  333. struct wps_er *wps_er;
  334. int blacklist_cleared;
  335. struct wpabuf *pending_eapol_rx;
  336. struct os_time pending_eapol_rx_time;
  337. u8 pending_eapol_rx_src[ETH_ALEN];
  338. struct ibss_rsn *ibss_rsn;
  339. #ifdef CONFIG_SME
  340. struct {
  341. u8 ssid[32];
  342. size_t ssid_len;
  343. int freq;
  344. u8 assoc_req_ie[80];
  345. size_t assoc_req_ie_len;
  346. int mfp;
  347. int ft_used;
  348. u8 mobility_domain[2];
  349. u8 *ft_ies;
  350. size_t ft_ies_len;
  351. u8 prev_bssid[ETH_ALEN];
  352. int prev_bssid_set;
  353. } sme;
  354. #endif /* CONFIG_SME */
  355. #ifdef CONFIG_AP
  356. struct hostapd_iface *ap_iface;
  357. #endif /* CONFIG_AP */
  358. struct wpa_ssid *bgscan_ssid;
  359. const struct bgscan_ops *bgscan;
  360. void *bgscan_priv;
  361. };
  362. /* wpa_supplicant.c */
  363. int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
  364. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  365. const char * wpa_supplicant_state_txt(int state);
  366. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  367. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  368. struct wpa_scan_res *bss,
  369. struct wpa_ssid *ssid,
  370. u8 *wpa_ie, size_t *wpa_ie_len);
  371. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  372. struct wpa_scan_res *bss,
  373. struct wpa_ssid *ssid);
  374. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  375. struct wpa_ssid *ssid);
  376. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  377. int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
  378. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  379. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  380. int sec, int usec);
  381. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
  382. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  383. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  384. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  385. int reason_code);
  386. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  387. int reason_code);
  388. void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
  389. struct wpa_ssid *ssid);
  390. void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
  391. struct wpa_ssid *ssid);
  392. void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
  393. struct wpa_ssid *ssid);
  394. int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
  395. int ap_scan);
  396. int wpa_supplicant_set_debug_params(struct wpa_global *global,
  397. int debug_level, int debug_timestamp,
  398. int debug_show_keys);
  399. void wpa_show_license(void);
  400. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  401. struct wpa_interface *iface);
  402. int wpa_supplicant_remove_iface(struct wpa_global *global,
  403. struct wpa_supplicant *wpa_s);
  404. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  405. const char *ifname);
  406. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  407. int wpa_supplicant_run(struct wpa_global *global);
  408. void wpa_supplicant_deinit(struct wpa_global *global);
  409. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  410. struct wpa_ssid *ssid);
  411. /* scan.c */
  412. int wpa_supplicant_enabled_networks(struct wpa_config *conf);
  413. void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
  414. void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
  415. void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
  416. int scanning);
  417. struct wpa_driver_scan_params;
  418. int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
  419. struct wpa_driver_scan_params *params);
  420. /* events.c */
  421. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  422. #endif /* WPA_SUPPLICANT_I_H */