wpa_supplicant_i.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /*
  2. * wpa_supplicant - Internal definitions
  3. * Copyright (c) 2003-2009, 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 "utils/list.h"
  17. #include "common/defs.h"
  18. extern const char *wpa_supplicant_version;
  19. extern const char *wpa_supplicant_license;
  20. #ifndef CONFIG_NO_STDOUT_DEBUG
  21. extern const char *wpa_supplicant_full_license1;
  22. extern const char *wpa_supplicant_full_license2;
  23. extern const char *wpa_supplicant_full_license3;
  24. extern const char *wpa_supplicant_full_license4;
  25. extern const char *wpa_supplicant_full_license5;
  26. #endif /* CONFIG_NO_STDOUT_DEBUG */
  27. struct wpa_scan_result;
  28. struct wpa_scan_res;
  29. struct wpa_sm;
  30. struct wpa_supplicant;
  31. struct ibss_rsn;
  32. /*
  33. * Forward declarations of private structures used within the ctrl_iface
  34. * backends. Other parts of wpa_supplicant do not have access to data stored in
  35. * these structures.
  36. */
  37. struct ctrl_iface_priv;
  38. struct ctrl_iface_global_priv;
  39. struct wpas_dbus_priv;
  40. /**
  41. * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
  42. */
  43. struct wpa_interface {
  44. /**
  45. * confname - Configuration name (file or profile) name
  46. *
  47. * This can also be %NULL when a configuration file is not used. In
  48. * that case, ctrl_interface must be set to allow the interface to be
  49. * configured.
  50. */
  51. const char *confname;
  52. /**
  53. * ctrl_interface - Control interface parameter
  54. *
  55. * If a configuration file is not used, this variable can be used to
  56. * set the ctrl_interface parameter that would have otherwise been read
  57. * from the configuration file. If both confname and ctrl_interface are
  58. * set, ctrl_interface is used to override the value from configuration
  59. * file.
  60. */
  61. const char *ctrl_interface;
  62. /**
  63. * driver - Driver interface name, or %NULL to use the default driver
  64. */
  65. const char *driver;
  66. /**
  67. * driver_param - Driver interface parameters
  68. *
  69. * If a configuration file is not used, this variable can be used to
  70. * set the driver_param parameters that would have otherwise been read
  71. * from the configuration file. If both confname and driver_param are
  72. * set, driver_param is used to override the value from configuration
  73. * file.
  74. */
  75. const char *driver_param;
  76. /**
  77. * ifname - Interface name
  78. */
  79. const char *ifname;
  80. /**
  81. * bridge_ifname - Optional bridge interface name
  82. *
  83. * If the driver interface (ifname) is included in a Linux bridge
  84. * device, the bridge interface may need to be used for receiving EAPOL
  85. * frames. This can be enabled by setting this variable to enable
  86. * receiving of EAPOL frames from an additional interface.
  87. */
  88. const char *bridge_ifname;
  89. };
  90. /**
  91. * struct wpa_params - Parameters for wpa_supplicant_init()
  92. */
  93. struct wpa_params {
  94. /**
  95. * daemonize - Run %wpa_supplicant in the background
  96. */
  97. int daemonize;
  98. /**
  99. * wait_for_monitor - Wait for a monitor program before starting
  100. */
  101. int wait_for_monitor;
  102. /**
  103. * pid_file - Path to a PID (process ID) file
  104. *
  105. * If this and daemonize are set, process ID of the background process
  106. * will be written to the specified file.
  107. */
  108. char *pid_file;
  109. /**
  110. * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
  111. */
  112. int wpa_debug_level;
  113. /**
  114. * wpa_debug_show_keys - Whether keying material is included in debug
  115. *
  116. * This parameter can be used to allow keying material to be included
  117. * in debug messages. This is a security risk and this option should
  118. * not be enabled in normal configuration. If needed during
  119. * development or while troubleshooting, this option can provide more
  120. * details for figuring out what is happening.
  121. */
  122. int wpa_debug_show_keys;
  123. /**
  124. * wpa_debug_timestamp - Whether to include timestamp in debug messages
  125. */
  126. int wpa_debug_timestamp;
  127. /**
  128. * ctrl_interface - Global ctrl_iface path/parameter
  129. */
  130. char *ctrl_interface;
  131. /**
  132. * dbus_ctrl_interface - Enable the DBus control interface
  133. */
  134. int dbus_ctrl_interface;
  135. /**
  136. * wpa_debug_file_path - Path of debug file or %NULL to use stdout
  137. */
  138. const char *wpa_debug_file_path;
  139. /**
  140. * wpa_debug_syslog - Enable log output through syslog
  141. */
  142. int wpa_debug_syslog;
  143. /**
  144. * override_driver - Optional driver parameter override
  145. *
  146. * This parameter can be used to override the driver parameter in
  147. * dynamic interface addition to force a specific driver wrapper to be
  148. * used instead.
  149. */
  150. char *override_driver;
  151. /**
  152. * override_ctrl_interface - Optional ctrl_interface override
  153. *
  154. * This parameter can be used to override the ctrl_interface parameter
  155. * in dynamic interface addition to force a control interface to be
  156. * created.
  157. */
  158. char *override_ctrl_interface;
  159. };
  160. /**
  161. * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
  162. *
  163. * This structure is initialized by calling wpa_supplicant_init() when starting
  164. * %wpa_supplicant.
  165. */
  166. struct wpa_global {
  167. struct wpa_supplicant *ifaces;
  168. struct wpa_params params;
  169. struct ctrl_iface_global_priv *ctrl_iface;
  170. struct wpas_dbus_priv *dbus;
  171. void **drv_priv;
  172. size_t drv_count;
  173. };
  174. struct wpa_client_mlme {
  175. #ifdef CONFIG_CLIENT_MLME
  176. enum {
  177. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  178. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  179. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
  180. } state;
  181. u8 prev_bssid[ETH_ALEN];
  182. u8 ssid[32];
  183. size_t ssid_len;
  184. u16 aid;
  185. u16 ap_capab, capab;
  186. u8 *extra_ie; /* to be added to the end of AssocReq */
  187. size_t extra_ie_len;
  188. u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
  189. size_t extra_probe_ie_len;
  190. enum wpa_key_mgmt key_mgmt;
  191. /* The last AssocReq/Resp IEs */
  192. u8 *assocreq_ies, *assocresp_ies;
  193. size_t assocreq_ies_len, assocresp_ies_len;
  194. int auth_tries, assoc_tries;
  195. unsigned int ssid_set:1;
  196. unsigned int bssid_set:1;
  197. unsigned int prev_bssid_set:1;
  198. unsigned int authenticated:1;
  199. unsigned int associated:1;
  200. unsigned int probereq_poll:1;
  201. unsigned int use_protection:1;
  202. unsigned int create_ibss:1;
  203. unsigned int mixed_cell:1;
  204. unsigned int wmm_enabled:1;
  205. struct os_time last_probe;
  206. #define IEEE80211_AUTH_ALG_OPEN BIT(0)
  207. #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
  208. #define IEEE80211_AUTH_ALG_LEAP BIT(2)
  209. unsigned int auth_algs; /* bitfield of allowed auth algs */
  210. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  211. int auth_transaction;
  212. struct os_time ibss_join_req;
  213. u8 *probe_resp; /* ProbeResp template for IBSS */
  214. size_t probe_resp_len;
  215. u32 supp_rates_bits;
  216. int wmm_last_param_set;
  217. int sta_scanning;
  218. int scan_hw_mode_idx;
  219. int scan_channel_idx;
  220. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  221. struct os_time last_scan_completed;
  222. int scan_oper_channel;
  223. int scan_oper_freq;
  224. int scan_oper_phymode;
  225. u8 scan_ssid[32];
  226. size_t scan_ssid_len;
  227. int scan_skip_11b;
  228. int *scan_freqs;
  229. struct ieee80211_sta_bss *sta_bss_list;
  230. #define STA_HASH_SIZE 256
  231. #define STA_HASH(sta) (sta[5])
  232. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  233. int cts_protect_erp_frames;
  234. enum hostapd_hw_mode phymode; /* current mode */
  235. struct hostapd_hw_modes *modes;
  236. size_t num_modes;
  237. unsigned int hw_modes; /* bitfield of allowed hardware modes;
  238. * (1 << HOSTAPD_MODE_*) */
  239. int num_curr_rates;
  240. int *curr_rates;
  241. int freq; /* The current frequency in MHz */
  242. int channel; /* The current IEEE 802.11 channel number */
  243. #ifdef CONFIG_IEEE80211R
  244. u8 current_md[6];
  245. u8 *ft_ies;
  246. size_t ft_ies_len;
  247. #endif /* CONFIG_IEEE80211R */
  248. #else /* CONFIG_CLIENT_MLME */
  249. int dummy; /* to keep MSVC happy */
  250. #endif /* CONFIG_CLIENT_MLME */
  251. };
  252. /**
  253. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  254. *
  255. * This structure contains the internal data for core wpa_supplicant code. This
  256. * should be only used directly from the core code. However, a pointer to this
  257. * data is used from other files as an arbitrary context pointer in calls to
  258. * core functions.
  259. */
  260. struct wpa_supplicant {
  261. struct wpa_global *global;
  262. struct wpa_supplicant *next;
  263. struct l2_packet_data *l2;
  264. struct l2_packet_data *l2_br;
  265. unsigned char own_addr[ETH_ALEN];
  266. char ifname[100];
  267. #ifdef CONFIG_CTRL_IFACE_DBUS
  268. char *dbus_path;
  269. #endif /* CONFIG_CTRL_IFACE_DBUS */
  270. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  271. char *dbus_new_path;
  272. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  273. char bridge_ifname[16];
  274. char *confname;
  275. struct wpa_config *conf;
  276. int countermeasures;
  277. os_time_t last_michael_mic_error;
  278. u8 bssid[ETH_ALEN];
  279. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  280. * field contains the targer BSSID. */
  281. int reassociate; /* reassociation requested */
  282. int disconnected; /* all connections disabled; i.e., do no reassociate
  283. * before this has been cleared */
  284. struct wpa_ssid *current_ssid;
  285. int ap_ies_from_associnfo;
  286. unsigned int assoc_freq;
  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 dl_list bss; /* struct wpa_bss::list */
  303. struct dl_list bss_id; /* struct wpa_bss::list_id */
  304. size_t num_bss;
  305. unsigned int bss_update_idx;
  306. unsigned int bss_next_id;
  307. struct wpa_driver_ops *driver;
  308. int interface_removed; /* whether the network interface has been
  309. * removed */
  310. struct wpa_sm *wpa;
  311. struct eapol_sm *eapol;
  312. struct ctrl_iface_priv *ctrl_iface;
  313. enum wpa_states wpa_state;
  314. int scanning;
  315. int new_connection;
  316. int reassociated_connection;
  317. int eapol_received; /* number of EAPOL packets received after the
  318. * previous association event */
  319. struct scard_data *scard;
  320. unsigned char last_eapol_src[ETH_ALEN];
  321. int keys_cleared;
  322. struct wpa_blacklist *blacklist;
  323. int scan_req; /* manual scan request; this forces a scan even if there
  324. * are no enabled networks in the configuration */
  325. int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
  326. * results without a new scan request; this is used
  327. * to speed up the first association if the driver
  328. * has already available scan results. */
  329. int scan_runs; /* number of scan runs since WPS was started */
  330. struct wpa_client_mlme mlme;
  331. unsigned int drv_flags;
  332. int max_scan_ssids;
  333. int pending_mic_error_report;
  334. int pending_mic_error_pairwise;
  335. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  336. struct wps_context *wps;
  337. int wps_success; /* WPS success event received */
  338. struct wps_er *wps_er;
  339. int blacklist_cleared;
  340. struct wpabuf *pending_eapol_rx;
  341. struct os_time pending_eapol_rx_time;
  342. u8 pending_eapol_rx_src[ETH_ALEN];
  343. struct ibss_rsn *ibss_rsn;
  344. #ifdef CONFIG_SME
  345. struct {
  346. u8 ssid[32];
  347. size_t ssid_len;
  348. int freq;
  349. u8 assoc_req_ie[80];
  350. size_t assoc_req_ie_len;
  351. int mfp;
  352. int ft_used;
  353. u8 mobility_domain[2];
  354. u8 *ft_ies;
  355. size_t ft_ies_len;
  356. u8 prev_bssid[ETH_ALEN];
  357. int prev_bssid_set;
  358. } sme;
  359. #endif /* CONFIG_SME */
  360. #ifdef CONFIG_AP
  361. struct hostapd_iface *ap_iface;
  362. #endif /* CONFIG_AP */
  363. struct wpa_ssid *bgscan_ssid;
  364. const struct bgscan_ops *bgscan;
  365. void *bgscan_priv;
  366. };
  367. /* wpa_supplicant.c */
  368. int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
  369. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  370. const char * wpa_supplicant_state_txt(enum wpa_states state);
  371. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  372. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  373. struct wpa_scan_res *bss,
  374. struct wpa_ssid *ssid,
  375. u8 *wpa_ie, size_t *wpa_ie_len);
  376. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  377. struct wpa_scan_res *bss,
  378. struct wpa_ssid *ssid);
  379. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  380. struct wpa_ssid *ssid);
  381. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  382. int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
  383. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  384. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  385. int sec, int usec);
  386. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
  387. enum wpa_states state);
  388. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  389. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  390. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  391. int reason_code);
  392. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  393. int reason_code);
  394. void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
  395. struct wpa_ssid *ssid);
  396. void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
  397. struct wpa_ssid *ssid);
  398. void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
  399. struct wpa_ssid *ssid);
  400. int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
  401. int ap_scan);
  402. int wpa_supplicant_set_debug_params(struct wpa_global *global,
  403. int debug_level, int debug_timestamp,
  404. int debug_show_keys);
  405. void wpa_show_license(void);
  406. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  407. struct wpa_interface *iface);
  408. int wpa_supplicant_remove_iface(struct wpa_global *global,
  409. struct wpa_supplicant *wpa_s);
  410. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  411. const char *ifname);
  412. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  413. int wpa_supplicant_run(struct wpa_global *global);
  414. void wpa_supplicant_deinit(struct wpa_global *global);
  415. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  416. struct wpa_ssid *ssid);
  417. void wpa_supplicant_terminate_proc(struct wpa_global *global);
  418. /* scan.c */
  419. int wpa_supplicant_enabled_networks(struct wpa_config *conf);
  420. void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
  421. void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
  422. void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
  423. int scanning);
  424. struct wpa_driver_scan_params;
  425. int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
  426. struct wpa_driver_scan_params *params);
  427. /* events.c */
  428. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  429. /* eap_register.c */
  430. int eap_register_methods(void);
  431. #endif /* WPA_SUPPLICANT_I_H */