wpa_supplicant_i.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. struct p2p_srv_bonjour {
  162. struct dl_list list;
  163. struct wpabuf *query;
  164. struct wpabuf *resp;
  165. };
  166. struct p2p_srv_upnp {
  167. struct dl_list list;
  168. u8 version;
  169. char *service;
  170. };
  171. /**
  172. * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
  173. *
  174. * This structure is initialized by calling wpa_supplicant_init() when starting
  175. * %wpa_supplicant.
  176. */
  177. struct wpa_global {
  178. struct wpa_supplicant *ifaces;
  179. struct wpa_params params;
  180. struct ctrl_iface_global_priv *ctrl_iface;
  181. struct wpas_dbus_priv *dbus;
  182. void **drv_priv;
  183. size_t drv_count;
  184. struct os_time suspend_time;
  185. struct p2p_data *p2p;
  186. struct wpa_supplicant *p2p_group_formation;
  187. u8 p2p_dev_addr[ETH_ALEN];
  188. struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
  189. struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
  190. int p2p_disabled;
  191. };
  192. struct wpa_client_mlme {
  193. #ifdef CONFIG_CLIENT_MLME
  194. enum {
  195. IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
  196. IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
  197. IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
  198. } state;
  199. u8 prev_bssid[ETH_ALEN];
  200. u8 ssid[32];
  201. size_t ssid_len;
  202. u16 aid;
  203. u16 ap_capab, capab;
  204. u8 *extra_ie; /* to be added to the end of AssocReq */
  205. size_t extra_ie_len;
  206. u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
  207. size_t extra_probe_ie_len;
  208. enum wpa_key_mgmt key_mgmt;
  209. /* The last AssocReq/Resp IEs */
  210. u8 *assocreq_ies, *assocresp_ies;
  211. size_t assocreq_ies_len, assocresp_ies_len;
  212. int auth_tries, assoc_tries;
  213. unsigned int ssid_set:1;
  214. unsigned int bssid_set:1;
  215. unsigned int prev_bssid_set:1;
  216. unsigned int authenticated:1;
  217. unsigned int associated:1;
  218. unsigned int probereq_poll:1;
  219. unsigned int use_protection:1;
  220. unsigned int create_ibss:1;
  221. unsigned int mixed_cell:1;
  222. unsigned int wmm_enabled:1;
  223. struct os_time last_probe;
  224. unsigned int auth_algs; /* bitfield of allowed auth algs
  225. * (WPA_AUTH_ALG_*) */
  226. int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
  227. int auth_transaction;
  228. struct os_time ibss_join_req;
  229. u8 *probe_resp; /* ProbeResp template for IBSS */
  230. size_t probe_resp_len;
  231. u32 supp_rates_bits;
  232. int wmm_last_param_set;
  233. int sta_scanning;
  234. int scan_hw_mode_idx;
  235. int scan_channel_idx;
  236. enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
  237. struct os_time last_scan_completed;
  238. int scan_oper_channel;
  239. int scan_oper_freq;
  240. int scan_oper_phymode;
  241. u8 scan_ssid[32];
  242. size_t scan_ssid_len;
  243. int scan_skip_11b;
  244. int *scan_freqs;
  245. struct ieee80211_sta_bss *sta_bss_list;
  246. #define STA_HASH_SIZE 256
  247. #define STA_HASH(sta) (sta[5])
  248. struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
  249. int cts_protect_erp_frames;
  250. enum hostapd_hw_mode phymode; /* current mode */
  251. struct hostapd_hw_modes *modes;
  252. size_t num_modes;
  253. unsigned int hw_modes; /* bitfield of allowed hardware modes;
  254. * (1 << HOSTAPD_MODE_*) */
  255. int num_curr_rates;
  256. int *curr_rates;
  257. int freq; /* The current frequency in MHz */
  258. int channel; /* The current IEEE 802.11 channel number */
  259. #ifdef CONFIG_IEEE80211R
  260. u8 current_md[6];
  261. u8 *ft_ies;
  262. size_t ft_ies_len;
  263. #endif /* CONFIG_IEEE80211R */
  264. void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
  265. int freq);
  266. void *public_action_cb_ctx;
  267. #else /* CONFIG_CLIENT_MLME */
  268. int dummy; /* to keep MSVC happy */
  269. #endif /* CONFIG_CLIENT_MLME */
  270. };
  271. /**
  272. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  273. *
  274. * This structure contains the internal data for core wpa_supplicant code. This
  275. * should be only used directly from the core code. However, a pointer to this
  276. * data is used from other files as an arbitrary context pointer in calls to
  277. * core functions.
  278. */
  279. struct wpa_supplicant {
  280. struct wpa_global *global;
  281. struct wpa_supplicant *parent;
  282. struct wpa_supplicant *next;
  283. struct l2_packet_data *l2;
  284. struct l2_packet_data *l2_br;
  285. unsigned char own_addr[ETH_ALEN];
  286. char ifname[100];
  287. #ifdef CONFIG_CTRL_IFACE_DBUS
  288. char *dbus_path;
  289. #endif /* CONFIG_CTRL_IFACE_DBUS */
  290. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  291. char *dbus_new_path;
  292. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  293. char bridge_ifname[16];
  294. char *confname;
  295. struct wpa_config *conf;
  296. int countermeasures;
  297. os_time_t last_michael_mic_error;
  298. u8 bssid[ETH_ALEN];
  299. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  300. * field contains the targer BSSID. */
  301. int reassociate; /* reassociation requested */
  302. int disconnected; /* all connections disabled; i.e., do no reassociate
  303. * before this has been cleared */
  304. struct wpa_ssid *current_ssid;
  305. struct wpa_bss *current_bss;
  306. int ap_ies_from_associnfo;
  307. unsigned int assoc_freq;
  308. /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
  309. int pairwise_cipher;
  310. int group_cipher;
  311. int key_mgmt;
  312. int mgmt_group_cipher;
  313. void *drv_priv; /* private data used by driver_ops */
  314. void *global_drv_priv;
  315. struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
  316. * NULL = not yet initialized (start
  317. * with wildcard SSID)
  318. * WILDCARD_SSID_SCAN = wildcard
  319. * SSID was used in the previous scan
  320. */
  321. #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
  322. void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
  323. struct wpa_scan_results *scan_res);
  324. struct dl_list bss; /* struct wpa_bss::list */
  325. struct dl_list bss_id; /* struct wpa_bss::list_id */
  326. size_t num_bss;
  327. unsigned int bss_update_idx;
  328. unsigned int bss_next_id;
  329. struct wpa_driver_ops *driver;
  330. int interface_removed; /* whether the network interface has been
  331. * removed */
  332. struct wpa_sm *wpa;
  333. struct eapol_sm *eapol;
  334. struct ctrl_iface_priv *ctrl_iface;
  335. enum wpa_states wpa_state;
  336. int scanning;
  337. int new_connection;
  338. int reassociated_connection;
  339. int eapol_received; /* number of EAPOL packets received after the
  340. * previous association event */
  341. struct scard_data *scard;
  342. unsigned char last_eapol_src[ETH_ALEN];
  343. int keys_cleared;
  344. struct wpa_blacklist *blacklist;
  345. int scan_req; /* manual scan request; this forces a scan even if there
  346. * are no enabled networks in the configuration */
  347. int scan_runs; /* number of scan runs since WPS was started */
  348. struct wpa_client_mlme mlme;
  349. unsigned int drv_flags;
  350. int max_scan_ssids;
  351. unsigned int max_remain_on_chan;
  352. int pending_mic_error_report;
  353. int pending_mic_error_pairwise;
  354. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  355. struct wps_context *wps;
  356. int wps_success; /* WPS success event received */
  357. struct wps_er *wps_er;
  358. int blacklist_cleared;
  359. struct wpabuf *pending_eapol_rx;
  360. struct os_time pending_eapol_rx_time;
  361. u8 pending_eapol_rx_src[ETH_ALEN];
  362. struct ibss_rsn *ibss_rsn;
  363. #ifdef CONFIG_SME
  364. struct {
  365. u8 ssid[32];
  366. size_t ssid_len;
  367. int freq;
  368. u8 assoc_req_ie[200];
  369. size_t assoc_req_ie_len;
  370. int mfp;
  371. int ft_used;
  372. u8 mobility_domain[2];
  373. u8 *ft_ies;
  374. size_t ft_ies_len;
  375. u8 prev_bssid[ETH_ALEN];
  376. int prev_bssid_set;
  377. int auth_alg;
  378. } sme;
  379. #endif /* CONFIG_SME */
  380. #ifdef CONFIG_AP
  381. struct hostapd_iface *ap_iface;
  382. void (*ap_configured_cb)(void *ctx, void *data);
  383. void *ap_configured_cb_ctx;
  384. void *ap_configured_cb_data;
  385. #endif /* CONFIG_AP */
  386. #ifdef CONFIG_P2P
  387. struct p2p_go_neg_results *go_params;
  388. int create_p2p_iface;
  389. u8 pending_interface_addr[ETH_ALEN];
  390. char pending_interface_name[IFNAMSIZ];
  391. int pending_interface_type;
  392. int p2p_group_idx;
  393. unsigned int off_channel_freq;
  394. struct wpabuf *pending_action_tx;
  395. u8 pending_action_src[ETH_ALEN];
  396. u8 pending_action_dst[ETH_ALEN];
  397. u8 pending_action_bssid[ETH_ALEN];
  398. unsigned int pending_action_freq;
  399. int pending_action_without_roc;
  400. unsigned int pending_listen_freq;
  401. unsigned int pending_listen_duration;
  402. enum {
  403. NOT_P2P_GROUP_INTERFACE,
  404. P2P_GROUP_INTERFACE_PENDING,
  405. P2P_GROUP_INTERFACE_GO,
  406. P2P_GROUP_INTERFACE_CLIENT
  407. } p2p_group_interface;
  408. struct p2p_group *p2p_group;
  409. int p2p_long_listen;
  410. char p2p_pin[10];
  411. int p2p_sd_over_ctrl_iface;
  412. int p2p_in_provisioning;
  413. int pending_invite_ssid_id;
  414. int show_group_started;
  415. u8 go_dev_addr[ETH_ALEN];
  416. int pending_pd_before_join;
  417. u8 pending_join_iface_addr[ETH_ALEN];
  418. u8 pending_join_dev_addr[ETH_ALEN];
  419. int pending_join_wps_method;
  420. unsigned int roc_waiting_drv_freq;
  421. #endif /* CONFIG_P2P */
  422. struct wpa_ssid *bgscan_ssid;
  423. const struct bgscan_ops *bgscan;
  424. void *bgscan_priv;
  425. int connect_without_scan;
  426. int after_wps;
  427. unsigned int wps_freq;
  428. int wps_fragment_size;
  429. };
  430. /* wpa_supplicant.c */
  431. int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
  432. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  433. const char * wpa_supplicant_state_txt(enum wpa_states state);
  434. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  435. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  436. struct wpa_bss *bss, struct wpa_ssid *ssid,
  437. u8 *wpa_ie, size_t *wpa_ie_len);
  438. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  439. struct wpa_bss *bss,
  440. struct wpa_ssid *ssid);
  441. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  442. struct wpa_ssid *ssid);
  443. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  444. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  445. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  446. int sec, int usec);
  447. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
  448. enum wpa_states state);
  449. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  450. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  451. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  452. int reason_code);
  453. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  454. int reason_code);
  455. void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
  456. struct wpa_ssid *ssid);
  457. void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
  458. struct wpa_ssid *ssid);
  459. void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
  460. struct wpa_ssid *ssid);
  461. int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
  462. int ap_scan);
  463. int wpa_supplicant_set_debug_params(struct wpa_global *global,
  464. int debug_level, int debug_timestamp,
  465. int debug_show_keys);
  466. void wpa_show_license(void);
  467. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  468. struct wpa_interface *iface);
  469. int wpa_supplicant_remove_iface(struct wpa_global *global,
  470. struct wpa_supplicant *wpa_s);
  471. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  472. const char *ifname);
  473. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  474. int wpa_supplicant_run(struct wpa_global *global);
  475. void wpa_supplicant_deinit(struct wpa_global *global);
  476. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  477. struct wpa_ssid *ssid);
  478. void wpa_supplicant_terminate_proc(struct wpa_global *global);
  479. void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
  480. const u8 *buf, size_t len);
  481. enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
  482. enum wpa_cipher cipher_suite2driver(int cipher);
  483. void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
  484. void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
  485. /* events.c */
  486. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  487. void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
  488. struct wpa_bss *selected,
  489. struct wpa_ssid *ssid);
  490. /* eap_register.c */
  491. int eap_register_methods(void);
  492. #endif /* WPA_SUPPLICANT_I_H */