wpa_supplicant_i.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. /*
  2. * wpa_supplicant - Internal definitions
  3. * Copyright (c) 2003-2010, 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_sm;
  28. struct wpa_supplicant;
  29. struct ibss_rsn;
  30. struct scan_info;
  31. struct wpa_bss;
  32. struct wpa_scan_results;
  33. /*
  34. * Forward declarations of private structures used within the ctrl_iface
  35. * backends. Other parts of wpa_supplicant do not have access to data stored in
  36. * these structures.
  37. */
  38. struct ctrl_iface_priv;
  39. struct ctrl_iface_global_priv;
  40. struct wpas_dbus_priv;
  41. /**
  42. * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
  43. */
  44. struct wpa_interface {
  45. /**
  46. * confname - Configuration name (file or profile) name
  47. *
  48. * This can also be %NULL when a configuration file is not used. In
  49. * that case, ctrl_interface must be set to allow the interface to be
  50. * configured.
  51. */
  52. const char *confname;
  53. /**
  54. * ctrl_interface - Control interface parameter
  55. *
  56. * If a configuration file is not used, this variable can be used to
  57. * set the ctrl_interface parameter that would have otherwise been read
  58. * from the configuration file. If both confname and ctrl_interface are
  59. * set, ctrl_interface is used to override the value from configuration
  60. * file.
  61. */
  62. const char *ctrl_interface;
  63. /**
  64. * driver - Driver interface name, or %NULL to use the default driver
  65. */
  66. const char *driver;
  67. /**
  68. * driver_param - Driver interface parameters
  69. *
  70. * If a configuration file is not used, this variable can be used to
  71. * set the driver_param parameters that would have otherwise been read
  72. * from the configuration file. If both confname and driver_param are
  73. * set, driver_param is used to override the value from configuration
  74. * file.
  75. */
  76. const char *driver_param;
  77. /**
  78. * ifname - Interface name
  79. */
  80. const char *ifname;
  81. /**
  82. * bridge_ifname - Optional bridge interface name
  83. *
  84. * If the driver interface (ifname) is included in a Linux bridge
  85. * device, the bridge interface may need to be used for receiving EAPOL
  86. * frames. This can be enabled by setting this variable to enable
  87. * receiving of EAPOL frames from an additional interface.
  88. */
  89. const char *bridge_ifname;
  90. };
  91. /**
  92. * struct wpa_params - Parameters for wpa_supplicant_init()
  93. */
  94. struct wpa_params {
  95. /**
  96. * daemonize - Run %wpa_supplicant in the background
  97. */
  98. int daemonize;
  99. /**
  100. * wait_for_monitor - Wait for a monitor program before starting
  101. */
  102. int wait_for_monitor;
  103. /**
  104. * pid_file - Path to a PID (process ID) file
  105. *
  106. * If this and daemonize are set, process ID of the background process
  107. * will be written to the specified file.
  108. */
  109. char *pid_file;
  110. /**
  111. * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
  112. */
  113. int wpa_debug_level;
  114. /**
  115. * wpa_debug_show_keys - Whether keying material is included in debug
  116. *
  117. * This parameter can be used to allow keying material to be included
  118. * in debug messages. This is a security risk and this option should
  119. * not be enabled in normal configuration. If needed during
  120. * development or while troubleshooting, this option can provide more
  121. * details for figuring out what is happening.
  122. */
  123. int wpa_debug_show_keys;
  124. /**
  125. * wpa_debug_timestamp - Whether to include timestamp in debug messages
  126. */
  127. int wpa_debug_timestamp;
  128. /**
  129. * ctrl_interface - Global ctrl_iface path/parameter
  130. */
  131. char *ctrl_interface;
  132. /**
  133. * dbus_ctrl_interface - Enable the DBus control interface
  134. */
  135. int dbus_ctrl_interface;
  136. /**
  137. * wpa_debug_file_path - Path of debug file or %NULL to use stdout
  138. */
  139. const char *wpa_debug_file_path;
  140. /**
  141. * wpa_debug_syslog - Enable log output through syslog
  142. */
  143. int wpa_debug_syslog;
  144. /**
  145. * override_driver - Optional driver parameter override
  146. *
  147. * This parameter can be used to override the driver parameter in
  148. * dynamic interface addition to force a specific driver wrapper to be
  149. * used instead.
  150. */
  151. char *override_driver;
  152. /**
  153. * override_ctrl_interface - Optional ctrl_interface override
  154. *
  155. * This parameter can be used to override the ctrl_interface parameter
  156. * in dynamic interface addition to force a control interface to be
  157. * created.
  158. */
  159. char *override_ctrl_interface;
  160. };
  161. /**
  162. * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
  163. *
  164. * This structure is initialized by calling wpa_supplicant_init() when starting
  165. * %wpa_supplicant.
  166. */
  167. struct wpa_global {
  168. struct wpa_supplicant *ifaces;
  169. struct wpa_params params;
  170. struct ctrl_iface_global_priv *ctrl_iface;
  171. struct wpas_dbus_priv *dbus;
  172. void **drv_priv;
  173. size_t drv_count;
  174. struct os_time suspend_time;
  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. enum 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. unsigned int auth_algs; /* bitfield of allowed auth algs
  209. * (WPA_AUTH_ALG_*) */
  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. void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
  249. int freq);
  250. void *public_action_cb_ctx;
  251. #else /* CONFIG_CLIENT_MLME */
  252. int dummy; /* to keep MSVC happy */
  253. #endif /* CONFIG_CLIENT_MLME */
  254. };
  255. /**
  256. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  257. *
  258. * This structure contains the internal data for core wpa_supplicant code. This
  259. * should be only used directly from the core code. However, a pointer to this
  260. * data is used from other files as an arbitrary context pointer in calls to
  261. * core functions.
  262. */
  263. struct wpa_supplicant {
  264. struct wpa_global *global;
  265. struct wpa_supplicant *next;
  266. struct l2_packet_data *l2;
  267. struct l2_packet_data *l2_br;
  268. unsigned char own_addr[ETH_ALEN];
  269. char ifname[100];
  270. #ifdef CONFIG_CTRL_IFACE_DBUS
  271. char *dbus_path;
  272. #endif /* CONFIG_CTRL_IFACE_DBUS */
  273. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  274. char *dbus_new_path;
  275. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  276. char bridge_ifname[16];
  277. char *confname;
  278. struct wpa_config *conf;
  279. int countermeasures;
  280. os_time_t last_michael_mic_error;
  281. u8 bssid[ETH_ALEN];
  282. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  283. * field contains the targer BSSID. */
  284. int reassociate; /* reassociation requested */
  285. int disconnected; /* all connections disabled; i.e., do no reassociate
  286. * before this has been cleared */
  287. struct wpa_ssid *current_ssid;
  288. struct wpa_bss *current_bss;
  289. int ap_ies_from_associnfo;
  290. unsigned int assoc_freq;
  291. /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
  292. int pairwise_cipher;
  293. int group_cipher;
  294. int key_mgmt;
  295. int mgmt_group_cipher;
  296. void *drv_priv; /* private data used by driver_ops */
  297. void *global_drv_priv;
  298. struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
  299. * NULL = not yet initialized (start
  300. * with wildcard SSID)
  301. * WILDCARD_SSID_SCAN = wildcard
  302. * SSID was used in the previous scan
  303. */
  304. #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
  305. void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
  306. struct wpa_scan_results *scan_res);
  307. struct dl_list bss; /* struct wpa_bss::list */
  308. struct dl_list bss_id; /* struct wpa_bss::list_id */
  309. size_t num_bss;
  310. unsigned int bss_update_idx;
  311. unsigned int bss_next_id;
  312. struct wpa_driver_ops *driver;
  313. int interface_removed; /* whether the network interface has been
  314. * removed */
  315. struct wpa_sm *wpa;
  316. struct eapol_sm *eapol;
  317. struct ctrl_iface_priv *ctrl_iface;
  318. enum wpa_states wpa_state;
  319. int scanning;
  320. int new_connection;
  321. int reassociated_connection;
  322. int eapol_received; /* number of EAPOL packets received after the
  323. * previous association event */
  324. struct scard_data *scard;
  325. unsigned char last_eapol_src[ETH_ALEN];
  326. int keys_cleared;
  327. struct wpa_blacklist *blacklist;
  328. int scan_req; /* manual scan request; this forces a scan even if there
  329. * are no enabled networks in the configuration */
  330. int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
  331. * results without a new scan request; this is used
  332. * to speed up the first association if the driver
  333. * has already available scan results. */
  334. int scan_runs; /* number of scan runs since WPS was started */
  335. struct wpa_client_mlme mlme;
  336. unsigned int drv_flags;
  337. int max_scan_ssids;
  338. unsigned int max_remain_on_chan;
  339. int pending_mic_error_report;
  340. int pending_mic_error_pairwise;
  341. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  342. struct wps_context *wps;
  343. int wps_success; /* WPS success event received */
  344. struct wps_er *wps_er;
  345. int blacklist_cleared;
  346. struct wpabuf *pending_eapol_rx;
  347. struct os_time pending_eapol_rx_time;
  348. u8 pending_eapol_rx_src[ETH_ALEN];
  349. struct ibss_rsn *ibss_rsn;
  350. #ifdef CONFIG_SME
  351. struct {
  352. u8 ssid[32];
  353. size_t ssid_len;
  354. int freq;
  355. u8 assoc_req_ie[80];
  356. size_t assoc_req_ie_len;
  357. int mfp;
  358. int ft_used;
  359. u8 mobility_domain[2];
  360. u8 *ft_ies;
  361. size_t ft_ies_len;
  362. u8 prev_bssid[ETH_ALEN];
  363. int prev_bssid_set;
  364. int auth_alg;
  365. } sme;
  366. #endif /* CONFIG_SME */
  367. #ifdef CONFIG_AP
  368. struct hostapd_iface *ap_iface;
  369. void (*ap_configured_cb)(void *ctx, void *data);
  370. void *ap_configured_cb_ctx;
  371. void *ap_configured_cb_data;
  372. #endif /* CONFIG_AP */
  373. struct wpa_ssid *bgscan_ssid;
  374. const struct bgscan_ops *bgscan;
  375. void *bgscan_priv;
  376. int connect_without_scan;
  377. int after_wps;
  378. unsigned int wps_freq;
  379. };
  380. /* wpa_supplicant.c */
  381. int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
  382. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  383. const char * wpa_supplicant_state_txt(enum wpa_states state);
  384. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  385. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  386. struct wpa_bss *bss, struct wpa_ssid *ssid,
  387. u8 *wpa_ie, size_t *wpa_ie_len);
  388. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  389. struct wpa_bss *bss,
  390. struct wpa_ssid *ssid);
  391. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  392. struct wpa_ssid *ssid);
  393. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  394. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  395. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  396. int sec, int usec);
  397. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
  398. enum wpa_states state);
  399. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  400. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  401. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  402. int reason_code);
  403. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  404. int reason_code);
  405. void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
  406. struct wpa_ssid *ssid);
  407. void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
  408. struct wpa_ssid *ssid);
  409. void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
  410. struct wpa_ssid *ssid);
  411. int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
  412. int ap_scan);
  413. int wpa_supplicant_set_debug_params(struct wpa_global *global,
  414. int debug_level, int debug_timestamp,
  415. int debug_show_keys);
  416. void wpa_show_license(void);
  417. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  418. struct wpa_interface *iface);
  419. int wpa_supplicant_remove_iface(struct wpa_global *global,
  420. struct wpa_supplicant *wpa_s);
  421. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  422. const char *ifname);
  423. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  424. int wpa_supplicant_run(struct wpa_global *global);
  425. void wpa_supplicant_deinit(struct wpa_global *global);
  426. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  427. struct wpa_ssid *ssid);
  428. void wpa_supplicant_terminate_proc(struct wpa_global *global);
  429. void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
  430. const u8 *buf, size_t len);
  431. enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
  432. enum wpa_cipher cipher_suite2driver(int cipher);
  433. /* events.c */
  434. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  435. void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
  436. struct wpa_bss *selected,
  437. struct wpa_ssid *ssid);
  438. /* eap_register.c */
  439. int eap_register_methods(void);
  440. #endif /* WPA_SUPPLICANT_I_H */