wpa_supplicant_i.h 17 KB

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