wpa_supplicant_i.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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. #include "config_ssid.h"
  19. extern const char *wpa_supplicant_version;
  20. extern const char *wpa_supplicant_license;
  21. #ifndef CONFIG_NO_STDOUT_DEBUG
  22. extern const char *wpa_supplicant_full_license1;
  23. extern const char *wpa_supplicant_full_license2;
  24. extern const char *wpa_supplicant_full_license3;
  25. extern const char *wpa_supplicant_full_license4;
  26. extern const char *wpa_supplicant_full_license5;
  27. #endif /* CONFIG_NO_STDOUT_DEBUG */
  28. struct wpa_sm;
  29. struct wpa_supplicant;
  30. struct ibss_rsn;
  31. struct scan_info;
  32. struct wpa_bss;
  33. struct wpa_scan_results;
  34. struct hostapd_hw_modes;
  35. /*
  36. * Forward declarations of private structures used within the ctrl_iface
  37. * backends. Other parts of wpa_supplicant do not have access to data stored in
  38. * these structures.
  39. */
  40. struct ctrl_iface_priv;
  41. struct ctrl_iface_global_priv;
  42. struct wpas_dbus_priv;
  43. /**
  44. * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
  45. */
  46. struct wpa_interface {
  47. /**
  48. * confname - Configuration name (file or profile) name
  49. *
  50. * This can also be %NULL when a configuration file is not used. In
  51. * that case, ctrl_interface must be set to allow the interface to be
  52. * configured.
  53. */
  54. const char *confname;
  55. /**
  56. * ctrl_interface - Control interface parameter
  57. *
  58. * If a configuration file is not used, this variable can be used to
  59. * set the ctrl_interface parameter that would have otherwise been read
  60. * from the configuration file. If both confname and ctrl_interface are
  61. * set, ctrl_interface is used to override the value from configuration
  62. * file.
  63. */
  64. const char *ctrl_interface;
  65. /**
  66. * driver - Driver interface name, or %NULL to use the default driver
  67. */
  68. const char *driver;
  69. /**
  70. * driver_param - Driver interface parameters
  71. *
  72. * If a configuration file is not used, this variable can be used to
  73. * set the driver_param parameters that would have otherwise been read
  74. * from the configuration file. If both confname and driver_param are
  75. * set, driver_param is used to override the value from configuration
  76. * file.
  77. */
  78. const char *driver_param;
  79. /**
  80. * ifname - Interface name
  81. */
  82. const char *ifname;
  83. /**
  84. * bridge_ifname - Optional bridge interface name
  85. *
  86. * If the driver interface (ifname) is included in a Linux bridge
  87. * device, the bridge interface may need to be used for receiving EAPOL
  88. * frames. This can be enabled by setting this variable to enable
  89. * receiving of EAPOL frames from an additional interface.
  90. */
  91. const char *bridge_ifname;
  92. };
  93. /**
  94. * struct wpa_params - Parameters for wpa_supplicant_init()
  95. */
  96. struct wpa_params {
  97. /**
  98. * daemonize - Run %wpa_supplicant in the background
  99. */
  100. int daemonize;
  101. /**
  102. * wait_for_monitor - Wait for a monitor program before starting
  103. */
  104. int wait_for_monitor;
  105. /**
  106. * pid_file - Path to a PID (process ID) file
  107. *
  108. * If this and daemonize are set, process ID of the background process
  109. * will be written to the specified file.
  110. */
  111. char *pid_file;
  112. /**
  113. * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
  114. */
  115. int wpa_debug_level;
  116. /**
  117. * wpa_debug_show_keys - Whether keying material is included in debug
  118. *
  119. * This parameter can be used to allow keying material to be included
  120. * in debug messages. This is a security risk and this option should
  121. * not be enabled in normal configuration. If needed during
  122. * development or while troubleshooting, this option can provide more
  123. * details for figuring out what is happening.
  124. */
  125. int wpa_debug_show_keys;
  126. /**
  127. * wpa_debug_timestamp - Whether to include timestamp in debug messages
  128. */
  129. int wpa_debug_timestamp;
  130. /**
  131. * ctrl_interface - Global ctrl_iface path/parameter
  132. */
  133. char *ctrl_interface;
  134. /**
  135. * dbus_ctrl_interface - Enable the DBus control interface
  136. */
  137. int dbus_ctrl_interface;
  138. /**
  139. * wpa_debug_file_path - Path of debug file or %NULL to use stdout
  140. */
  141. const char *wpa_debug_file_path;
  142. /**
  143. * wpa_debug_syslog - Enable log output through syslog
  144. */
  145. int wpa_debug_syslog;
  146. /**
  147. * override_driver - Optional driver parameter override
  148. *
  149. * This parameter can be used to override the driver parameter in
  150. * dynamic interface addition to force a specific driver wrapper to be
  151. * used instead.
  152. */
  153. char *override_driver;
  154. /**
  155. * override_ctrl_interface - Optional ctrl_interface override
  156. *
  157. * This parameter can be used to override the ctrl_interface parameter
  158. * in dynamic interface addition to force a control interface to be
  159. * created.
  160. */
  161. char *override_ctrl_interface;
  162. /**
  163. * entropy_file - Optional entropy file
  164. *
  165. * This parameter can be used to configure wpa_supplicant to maintain
  166. * its internal entropy store over restarts.
  167. */
  168. char *entropy_file;
  169. };
  170. struct p2p_srv_bonjour {
  171. struct dl_list list;
  172. struct wpabuf *query;
  173. struct wpabuf *resp;
  174. };
  175. struct p2p_srv_upnp {
  176. struct dl_list list;
  177. u8 version;
  178. char *service;
  179. };
  180. /**
  181. * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
  182. *
  183. * This structure is initialized by calling wpa_supplicant_init() when starting
  184. * %wpa_supplicant.
  185. */
  186. struct wpa_global {
  187. struct wpa_supplicant *ifaces;
  188. struct wpa_params params;
  189. struct ctrl_iface_global_priv *ctrl_iface;
  190. struct wpas_dbus_priv *dbus;
  191. void **drv_priv;
  192. size_t drv_count;
  193. struct os_time suspend_time;
  194. struct p2p_data *p2p;
  195. struct wpa_supplicant *p2p_group_formation;
  196. u8 p2p_dev_addr[ETH_ALEN];
  197. struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
  198. struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
  199. int p2p_disabled;
  200. int cross_connection;
  201. };
  202. enum offchannel_send_action_result {
  203. OFFCHANNEL_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
  204. OFFCHANNEL_SEND_ACTION_NO_ACK /* Frame was sent, but not acknowledged
  205. */,
  206. OFFCHANNEL_SEND_ACTION_FAILED /* Frame was not sent due to a failure */
  207. };
  208. /**
  209. * struct wpa_supplicant - Internal data for wpa_supplicant interface
  210. *
  211. * This structure contains the internal data for core wpa_supplicant code. This
  212. * should be only used directly from the core code. However, a pointer to this
  213. * data is used from other files as an arbitrary context pointer in calls to
  214. * core functions.
  215. */
  216. struct wpa_supplicant {
  217. struct wpa_global *global;
  218. struct wpa_supplicant *parent;
  219. struct wpa_supplicant *next;
  220. struct l2_packet_data *l2;
  221. struct l2_packet_data *l2_br;
  222. unsigned char own_addr[ETH_ALEN];
  223. char ifname[100];
  224. #ifdef CONFIG_CTRL_IFACE_DBUS
  225. char *dbus_path;
  226. #endif /* CONFIG_CTRL_IFACE_DBUS */
  227. #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
  228. char *dbus_new_path;
  229. char *dbus_groupobj_path;
  230. #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
  231. char bridge_ifname[16];
  232. char *confname;
  233. struct wpa_config *conf;
  234. int countermeasures;
  235. os_time_t last_michael_mic_error;
  236. u8 bssid[ETH_ALEN];
  237. u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
  238. * field contains the target BSSID. */
  239. int reassociate; /* reassociation requested */
  240. int disconnected; /* all connections disabled; i.e., do no reassociate
  241. * before this has been cleared */
  242. struct wpa_ssid *current_ssid;
  243. struct wpa_bss *current_bss;
  244. int ap_ies_from_associnfo;
  245. unsigned int assoc_freq;
  246. /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
  247. int pairwise_cipher;
  248. int group_cipher;
  249. int key_mgmt;
  250. int wpa_proto;
  251. int mgmt_group_cipher;
  252. void *drv_priv; /* private data used by driver_ops */
  253. void *global_drv_priv;
  254. struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
  255. * NULL = not yet initialized (start
  256. * with wildcard SSID)
  257. * WILDCARD_SSID_SCAN = wildcard
  258. * SSID was used in the previous scan
  259. */
  260. #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
  261. struct wpa_ssid *prev_sched_ssid; /* last SSID used in sched scan */
  262. int sched_scan_timeout;
  263. int sched_scan_interval;
  264. int first_sched_scan;
  265. int sched_scan_timed_out;
  266. void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
  267. struct wpa_scan_results *scan_res);
  268. struct dl_list bss; /* struct wpa_bss::list */
  269. struct dl_list bss_id; /* struct wpa_bss::list_id */
  270. size_t num_bss;
  271. unsigned int bss_update_idx;
  272. unsigned int bss_next_id;
  273. struct wpa_driver_ops *driver;
  274. int interface_removed; /* whether the network interface has been
  275. * removed */
  276. struct wpa_sm *wpa;
  277. struct eapol_sm *eapol;
  278. struct ctrl_iface_priv *ctrl_iface;
  279. enum wpa_states wpa_state;
  280. int scanning;
  281. int sched_scanning;
  282. int new_connection;
  283. int reassociated_connection;
  284. int eapol_received; /* number of EAPOL packets received after the
  285. * previous association event */
  286. struct scard_data *scard;
  287. unsigned char last_eapol_src[ETH_ALEN];
  288. int keys_cleared;
  289. struct wpa_blacklist *blacklist;
  290. int scan_req; /* manual scan request; this forces a scan even if there
  291. * are no enabled networks in the configuration */
  292. int scan_runs; /* number of scan runs since WPS was started */
  293. int *next_scan_freqs;
  294. int scan_interval; /* time in sec between scans to find suitable AP */
  295. unsigned int drv_flags;
  296. int max_scan_ssids;
  297. int max_sched_scan_ssids;
  298. int sched_scan_supported;
  299. unsigned int max_match_sets;
  300. unsigned int max_remain_on_chan;
  301. unsigned int max_stations;
  302. int pending_mic_error_report;
  303. int pending_mic_error_pairwise;
  304. int mic_errors_seen; /* Michael MIC errors with the current PTK */
  305. struct wps_context *wps;
  306. int wps_success; /* WPS success event received */
  307. struct wps_er *wps_er;
  308. int blacklist_cleared;
  309. struct wpabuf *pending_eapol_rx;
  310. struct os_time pending_eapol_rx_time;
  311. u8 pending_eapol_rx_src[ETH_ALEN];
  312. struct ibss_rsn *ibss_rsn;
  313. int set_sta_uapsd;
  314. int sta_uapsd;
  315. int set_ap_uapsd;
  316. int ap_uapsd;
  317. #ifdef CONFIG_SME
  318. struct {
  319. u8 ssid[32];
  320. size_t ssid_len;
  321. int freq;
  322. u8 assoc_req_ie[200];
  323. size_t assoc_req_ie_len;
  324. int mfp;
  325. int ft_used;
  326. u8 mobility_domain[2];
  327. u8 *ft_ies;
  328. size_t ft_ies_len;
  329. u8 prev_bssid[ETH_ALEN];
  330. int prev_bssid_set;
  331. int auth_alg;
  332. int proto;
  333. int sa_query_count; /* number of pending SA Query requests;
  334. * 0 = no SA Query in progress */
  335. int sa_query_timed_out;
  336. u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
  337. * sa_query_count octets of pending
  338. * SA Query transaction identifiers */
  339. struct os_time sa_query_start;
  340. } sme;
  341. #endif /* CONFIG_SME */
  342. #ifdef CONFIG_AP
  343. struct hostapd_iface *ap_iface;
  344. void (*ap_configured_cb)(void *ctx, void *data);
  345. void *ap_configured_cb_ctx;
  346. void *ap_configured_cb_data;
  347. #endif /* CONFIG_AP */
  348. unsigned int off_channel_freq;
  349. struct wpabuf *pending_action_tx;
  350. u8 pending_action_src[ETH_ALEN];
  351. u8 pending_action_dst[ETH_ALEN];
  352. u8 pending_action_bssid[ETH_ALEN];
  353. unsigned int pending_action_freq;
  354. int pending_action_no_cck;
  355. int pending_action_without_roc;
  356. void (*pending_action_tx_status_cb)(struct wpa_supplicant *wpa_s,
  357. unsigned int freq, const u8 *dst,
  358. const u8 *src, const u8 *bssid,
  359. const u8 *data, size_t data_len,
  360. enum offchannel_send_action_result
  361. result);
  362. unsigned int roc_waiting_drv_freq;
  363. int action_tx_wait_time;
  364. #ifdef CONFIG_P2P
  365. struct p2p_go_neg_results *go_params;
  366. int create_p2p_iface;
  367. u8 pending_interface_addr[ETH_ALEN];
  368. char pending_interface_name[100];
  369. int pending_interface_type;
  370. int p2p_group_idx;
  371. unsigned int pending_listen_freq;
  372. unsigned int pending_listen_duration;
  373. enum {
  374. NOT_P2P_GROUP_INTERFACE,
  375. P2P_GROUP_INTERFACE_PENDING,
  376. P2P_GROUP_INTERFACE_GO,
  377. P2P_GROUP_INTERFACE_CLIENT
  378. } p2p_group_interface;
  379. struct p2p_group *p2p_group;
  380. int p2p_long_listen; /* remaining time in long Listen state in ms */
  381. char p2p_pin[10];
  382. int p2p_wps_method;
  383. u8 p2p_auth_invite[ETH_ALEN];
  384. int p2p_sd_over_ctrl_iface;
  385. int p2p_in_provisioning;
  386. int pending_invite_ssid_id;
  387. int show_group_started;
  388. u8 go_dev_addr[ETH_ALEN];
  389. int pending_pd_before_join;
  390. u8 pending_join_iface_addr[ETH_ALEN];
  391. u8 pending_join_dev_addr[ETH_ALEN];
  392. int pending_join_wps_method;
  393. int p2p_join_scan_count;
  394. int force_long_sd;
  395. /*
  396. * Whether cross connection is disallowed by the AP to which this
  397. * interface is associated (only valid if there is an association).
  398. */
  399. int cross_connect_disallowed;
  400. /*
  401. * Whether this P2P group is configured to use cross connection (only
  402. * valid if this is P2P GO interface). The actual cross connect packet
  403. * forwarding may not be configured depending on the uplink status.
  404. */
  405. int cross_connect_enabled;
  406. /* Whether cross connection forwarding is in use at the moment. */
  407. int cross_connect_in_use;
  408. /*
  409. * Uplink interface name for cross connection
  410. */
  411. char cross_connect_uplink[100];
  412. enum {
  413. P2P_GROUP_REMOVAL_UNKNOWN,
  414. P2P_GROUP_REMOVAL_REQUESTED,
  415. P2P_GROUP_REMOVAL_IDLE_TIMEOUT,
  416. P2P_GROUP_REMOVAL_UNAVAILABLE
  417. } removal_reason;
  418. unsigned int p2p_cb_on_scan_complete:1;
  419. #endif /* CONFIG_P2P */
  420. struct wpa_ssid *bgscan_ssid;
  421. const struct bgscan_ops *bgscan;
  422. void *bgscan_priv;
  423. struct wpa_ssid *connect_without_scan;
  424. int after_wps;
  425. unsigned int wps_freq;
  426. int wps_fragment_size;
  427. int auto_reconnect_disabled;
  428. /* Channel preferences for AP/P2P GO use */
  429. int best_24_freq;
  430. int best_5_freq;
  431. int best_overall_freq;
  432. struct gas_query *gas;
  433. #ifdef CONFIG_INTERWORKING
  434. unsigned int fetch_anqp_in_progress:1;
  435. unsigned int network_select:1;
  436. unsigned int auto_select:1;
  437. #endif /* CONFIG_INTERWORKING */
  438. unsigned int drv_capa_known;
  439. struct {
  440. struct hostapd_hw_modes *modes;
  441. u16 num_modes;
  442. u16 flags;
  443. } hw;
  444. };
  445. /* wpa_supplicant.c */
  446. int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
  447. int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
  448. const char * wpa_supplicant_state_txt(enum wpa_states state);
  449. int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
  450. int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
  451. struct wpa_bss *bss, struct wpa_ssid *ssid,
  452. u8 *wpa_ie, size_t *wpa_ie_len);
  453. void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
  454. struct wpa_bss *bss,
  455. struct wpa_ssid *ssid);
  456. void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
  457. struct wpa_ssid *ssid);
  458. void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
  459. void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
  460. void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
  461. int sec, int usec);
  462. void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
  463. enum wpa_states state);
  464. struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
  465. const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s);
  466. void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
  467. void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
  468. int reason_code);
  469. void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
  470. int reason_code);
  471. void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
  472. struct wpa_ssid *ssid);
  473. void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
  474. struct wpa_ssid *ssid);
  475. void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
  476. struct wpa_ssid *ssid);
  477. int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
  478. int ap_scan);
  479. int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,
  480. unsigned int expire_age);
  481. int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,
  482. unsigned int expire_count);
  483. int wpa_supplicant_set_debug_params(struct wpa_global *global,
  484. int debug_level, int debug_timestamp,
  485. int debug_show_keys);
  486. void wpa_show_license(void);
  487. struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
  488. struct wpa_interface *iface);
  489. int wpa_supplicant_remove_iface(struct wpa_global *global,
  490. struct wpa_supplicant *wpa_s);
  491. struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
  492. const char *ifname);
  493. struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
  494. int wpa_supplicant_run(struct wpa_global *global);
  495. void wpa_supplicant_deinit(struct wpa_global *global);
  496. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  497. struct wpa_ssid *ssid);
  498. void wpa_supplicant_terminate_proc(struct wpa_global *global);
  499. void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
  500. const u8 *buf, size_t len);
  501. enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
  502. enum wpa_cipher cipher_suite2driver(int cipher);
  503. void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
  504. void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
  505. void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid);
  506. int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s);
  507. /* events.c */
  508. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
  509. int wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
  510. struct wpa_bss *selected,
  511. struct wpa_ssid *ssid);
  512. void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx);
  513. void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx);
  514. /* eap_register.c */
  515. int eap_register_methods(void);
  516. /**
  517. * Utility method to tell if a given network is a persistent group
  518. * @ssid: Network object
  519. * Returns: 1 if network is a persistent group, 0 otherwise
  520. */
  521. static inline int network_is_persistent_group(struct wpa_ssid *ssid)
  522. {
  523. return ((ssid->disabled == 2) || ssid->p2p_persistent_group);
  524. }
  525. #endif /* WPA_SUPPLICANT_I_H */