]> git.ipfire.org Git - thirdparty/hostap.git/blob - wpa_supplicant/wpa_supplicant_i.h
P2P: Add support for cross connection
[thirdparty/hostap.git] / wpa_supplicant / wpa_supplicant_i.h
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
15 #ifndef WPA_SUPPLICANT_I_H
16 #define WPA_SUPPLICANT_I_H
17
18 #include "utils/list.h"
19 #include "common/defs.h"
20
21 extern const char *wpa_supplicant_version;
22 extern const char *wpa_supplicant_license;
23 #ifndef CONFIG_NO_STDOUT_DEBUG
24 extern const char *wpa_supplicant_full_license1;
25 extern const char *wpa_supplicant_full_license2;
26 extern const char *wpa_supplicant_full_license3;
27 extern const char *wpa_supplicant_full_license4;
28 extern const char *wpa_supplicant_full_license5;
29 #endif /* CONFIG_NO_STDOUT_DEBUG */
30
31 struct wpa_sm;
32 struct wpa_supplicant;
33 struct ibss_rsn;
34 struct scan_info;
35 struct wpa_bss;
36 struct wpa_scan_results;
37
38 /*
39 * Forward declarations of private structures used within the ctrl_iface
40 * backends. Other parts of wpa_supplicant do not have access to data stored in
41 * these structures.
42 */
43 struct ctrl_iface_priv;
44 struct ctrl_iface_global_priv;
45 struct wpas_dbus_priv;
46
47 /**
48 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
49 */
50 struct wpa_interface {
51 /**
52 * confname - Configuration name (file or profile) name
53 *
54 * This can also be %NULL when a configuration file is not used. In
55 * that case, ctrl_interface must be set to allow the interface to be
56 * configured.
57 */
58 const char *confname;
59
60 /**
61 * ctrl_interface - Control interface parameter
62 *
63 * If a configuration file is not used, this variable can be used to
64 * set the ctrl_interface parameter that would have otherwise been read
65 * from the configuration file. If both confname and ctrl_interface are
66 * set, ctrl_interface is used to override the value from configuration
67 * file.
68 */
69 const char *ctrl_interface;
70
71 /**
72 * driver - Driver interface name, or %NULL to use the default driver
73 */
74 const char *driver;
75
76 /**
77 * driver_param - Driver interface parameters
78 *
79 * If a configuration file is not used, this variable can be used to
80 * set the driver_param parameters that would have otherwise been read
81 * from the configuration file. If both confname and driver_param are
82 * set, driver_param is used to override the value from configuration
83 * file.
84 */
85 const char *driver_param;
86
87 /**
88 * ifname - Interface name
89 */
90 const char *ifname;
91
92 /**
93 * bridge_ifname - Optional bridge interface name
94 *
95 * If the driver interface (ifname) is included in a Linux bridge
96 * device, the bridge interface may need to be used for receiving EAPOL
97 * frames. This can be enabled by setting this variable to enable
98 * receiving of EAPOL frames from an additional interface.
99 */
100 const char *bridge_ifname;
101 };
102
103 /**
104 * struct wpa_params - Parameters for wpa_supplicant_init()
105 */
106 struct wpa_params {
107 /**
108 * daemonize - Run %wpa_supplicant in the background
109 */
110 int daemonize;
111
112 /**
113 * wait_for_monitor - Wait for a monitor program before starting
114 */
115 int wait_for_monitor;
116
117 /**
118 * pid_file - Path to a PID (process ID) file
119 *
120 * If this and daemonize are set, process ID of the background process
121 * will be written to the specified file.
122 */
123 char *pid_file;
124
125 /**
126 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
127 */
128 int wpa_debug_level;
129
130 /**
131 * wpa_debug_show_keys - Whether keying material is included in debug
132 *
133 * This parameter can be used to allow keying material to be included
134 * in debug messages. This is a security risk and this option should
135 * not be enabled in normal configuration. If needed during
136 * development or while troubleshooting, this option can provide more
137 * details for figuring out what is happening.
138 */
139 int wpa_debug_show_keys;
140
141 /**
142 * wpa_debug_timestamp - Whether to include timestamp in debug messages
143 */
144 int wpa_debug_timestamp;
145
146 /**
147 * ctrl_interface - Global ctrl_iface path/parameter
148 */
149 char *ctrl_interface;
150
151 /**
152 * dbus_ctrl_interface - Enable the DBus control interface
153 */
154 int dbus_ctrl_interface;
155
156 /**
157 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
158 */
159 const char *wpa_debug_file_path;
160
161 /**
162 * wpa_debug_syslog - Enable log output through syslog
163 */
164 int wpa_debug_syslog;
165
166 /**
167 * override_driver - Optional driver parameter override
168 *
169 * This parameter can be used to override the driver parameter in
170 * dynamic interface addition to force a specific driver wrapper to be
171 * used instead.
172 */
173 char *override_driver;
174
175 /**
176 * override_ctrl_interface - Optional ctrl_interface override
177 *
178 * This parameter can be used to override the ctrl_interface parameter
179 * in dynamic interface addition to force a control interface to be
180 * created.
181 */
182 char *override_ctrl_interface;
183 };
184
185 struct p2p_srv_bonjour {
186 struct dl_list list;
187 struct wpabuf *query;
188 struct wpabuf *resp;
189 };
190
191 struct p2p_srv_upnp {
192 struct dl_list list;
193 u8 version;
194 char *service;
195 };
196
197 /**
198 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
199 *
200 * This structure is initialized by calling wpa_supplicant_init() when starting
201 * %wpa_supplicant.
202 */
203 struct wpa_global {
204 struct wpa_supplicant *ifaces;
205 struct wpa_params params;
206 struct ctrl_iface_global_priv *ctrl_iface;
207 struct wpas_dbus_priv *dbus;
208 void **drv_priv;
209 size_t drv_count;
210 struct os_time suspend_time;
211 struct p2p_data *p2p;
212 struct wpa_supplicant *p2p_group_formation;
213 u8 p2p_dev_addr[ETH_ALEN];
214 struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
215 struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
216 int p2p_disabled;
217 int cross_connection;
218 };
219
220
221 struct wpa_client_mlme {
222 #ifdef CONFIG_CLIENT_MLME
223 enum {
224 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
225 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
226 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
227 } state;
228 u8 prev_bssid[ETH_ALEN];
229 u8 ssid[32];
230 size_t ssid_len;
231 u16 aid;
232 u16 ap_capab, capab;
233 u8 *extra_ie; /* to be added to the end of AssocReq */
234 size_t extra_ie_len;
235 u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
236 size_t extra_probe_ie_len;
237 enum wpa_key_mgmt key_mgmt;
238
239 /* The last AssocReq/Resp IEs */
240 u8 *assocreq_ies, *assocresp_ies;
241 size_t assocreq_ies_len, assocresp_ies_len;
242
243 int auth_tries, assoc_tries;
244
245 unsigned int ssid_set:1;
246 unsigned int bssid_set:1;
247 unsigned int prev_bssid_set:1;
248 unsigned int authenticated:1;
249 unsigned int associated:1;
250 unsigned int probereq_poll:1;
251 unsigned int use_protection:1;
252 unsigned int create_ibss:1;
253 unsigned int mixed_cell:1;
254 unsigned int wmm_enabled:1;
255
256 struct os_time last_probe;
257
258 unsigned int auth_algs; /* bitfield of allowed auth algs
259 * (WPA_AUTH_ALG_*) */
260 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
261 int auth_transaction;
262
263 struct os_time ibss_join_req;
264 u8 *probe_resp; /* ProbeResp template for IBSS */
265 size_t probe_resp_len;
266 u32 supp_rates_bits;
267
268 int wmm_last_param_set;
269
270 int sta_scanning;
271 int scan_hw_mode_idx;
272 int scan_channel_idx;
273 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
274 struct os_time last_scan_completed;
275 int scan_oper_channel;
276 int scan_oper_freq;
277 int scan_oper_phymode;
278 u8 scan_ssid[32];
279 size_t scan_ssid_len;
280 int scan_skip_11b;
281 int *scan_freqs;
282
283 struct ieee80211_sta_bss *sta_bss_list;
284 #define STA_HASH_SIZE 256
285 #define STA_HASH(sta) (sta[5])
286 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
287
288 int cts_protect_erp_frames;
289
290 enum hostapd_hw_mode phymode; /* current mode */
291 struct hostapd_hw_modes *modes;
292 size_t num_modes;
293 unsigned int hw_modes; /* bitfield of allowed hardware modes;
294 * (1 << HOSTAPD_MODE_*) */
295 int num_curr_rates;
296 int *curr_rates;
297 int freq; /* The current frequency in MHz */
298 int channel; /* The current IEEE 802.11 channel number */
299
300 #ifdef CONFIG_IEEE80211R
301 u8 current_md[6];
302 u8 *ft_ies;
303 size_t ft_ies_len;
304 #endif /* CONFIG_IEEE80211R */
305
306 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
307 int freq);
308 void *public_action_cb_ctx;
309
310 #else /* CONFIG_CLIENT_MLME */
311 int dummy; /* to keep MSVC happy */
312 #endif /* CONFIG_CLIENT_MLME */
313 };
314
315 /**
316 * struct wpa_supplicant - Internal data for wpa_supplicant interface
317 *
318 * This structure contains the internal data for core wpa_supplicant code. This
319 * should be only used directly from the core code. However, a pointer to this
320 * data is used from other files as an arbitrary context pointer in calls to
321 * core functions.
322 */
323 struct wpa_supplicant {
324 struct wpa_global *global;
325 struct wpa_supplicant *parent;
326 struct wpa_supplicant *next;
327 struct l2_packet_data *l2;
328 struct l2_packet_data *l2_br;
329 unsigned char own_addr[ETH_ALEN];
330 char ifname[100];
331 #ifdef CONFIG_CTRL_IFACE_DBUS
332 char *dbus_path;
333 #endif /* CONFIG_CTRL_IFACE_DBUS */
334 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
335 char *dbus_new_path;
336 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
337 char bridge_ifname[16];
338
339 char *confname;
340 struct wpa_config *conf;
341 int countermeasures;
342 os_time_t last_michael_mic_error;
343 u8 bssid[ETH_ALEN];
344 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
345 * field contains the targer BSSID. */
346 int reassociate; /* reassociation requested */
347 int disconnected; /* all connections disabled; i.e., do no reassociate
348 * before this has been cleared */
349 struct wpa_ssid *current_ssid;
350 struct wpa_bss *current_bss;
351 int ap_ies_from_associnfo;
352 unsigned int assoc_freq;
353
354 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
355 int pairwise_cipher;
356 int group_cipher;
357 int key_mgmt;
358 int mgmt_group_cipher;
359
360 void *drv_priv; /* private data used by driver_ops */
361 void *global_drv_priv;
362
363 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
364 * NULL = not yet initialized (start
365 * with wildcard SSID)
366 * WILDCARD_SSID_SCAN = wildcard
367 * SSID was used in the previous scan
368 */
369 #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
370
371 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
372 struct wpa_scan_results *scan_res);
373 struct dl_list bss; /* struct wpa_bss::list */
374 struct dl_list bss_id; /* struct wpa_bss::list_id */
375 size_t num_bss;
376 unsigned int bss_update_idx;
377 unsigned int bss_next_id;
378
379 struct wpa_driver_ops *driver;
380 int interface_removed; /* whether the network interface has been
381 * removed */
382 struct wpa_sm *wpa;
383 struct eapol_sm *eapol;
384
385 struct ctrl_iface_priv *ctrl_iface;
386
387 enum wpa_states wpa_state;
388 int scanning;
389 int new_connection;
390 int reassociated_connection;
391
392 int eapol_received; /* number of EAPOL packets received after the
393 * previous association event */
394
395 struct scard_data *scard;
396
397 unsigned char last_eapol_src[ETH_ALEN];
398
399 int keys_cleared;
400
401 struct wpa_blacklist *blacklist;
402
403 int scan_req; /* manual scan request; this forces a scan even if there
404 * are no enabled networks in the configuration */
405 int scan_runs; /* number of scan runs since WPS was started */
406
407 struct wpa_client_mlme mlme;
408 unsigned int drv_flags;
409 int max_scan_ssids;
410 unsigned int max_remain_on_chan;
411
412 int pending_mic_error_report;
413 int pending_mic_error_pairwise;
414 int mic_errors_seen; /* Michael MIC errors with the current PTK */
415
416 struct wps_context *wps;
417 int wps_success; /* WPS success event received */
418 struct wps_er *wps_er;
419 int blacklist_cleared;
420
421 struct wpabuf *pending_eapol_rx;
422 struct os_time pending_eapol_rx_time;
423 u8 pending_eapol_rx_src[ETH_ALEN];
424
425 struct ibss_rsn *ibss_rsn;
426
427 #ifdef CONFIG_SME
428 struct {
429 u8 ssid[32];
430 size_t ssid_len;
431 int freq;
432 u8 assoc_req_ie[200];
433 size_t assoc_req_ie_len;
434 int mfp;
435 int ft_used;
436 u8 mobility_domain[2];
437 u8 *ft_ies;
438 size_t ft_ies_len;
439 u8 prev_bssid[ETH_ALEN];
440 int prev_bssid_set;
441 int auth_alg;
442 } sme;
443 #endif /* CONFIG_SME */
444
445 #ifdef CONFIG_AP
446 struct hostapd_iface *ap_iface;
447 void (*ap_configured_cb)(void *ctx, void *data);
448 void *ap_configured_cb_ctx;
449 void *ap_configured_cb_data;
450 #endif /* CONFIG_AP */
451
452 #ifdef CONFIG_P2P
453 struct p2p_go_neg_results *go_params;
454 int create_p2p_iface;
455 u8 pending_interface_addr[ETH_ALEN];
456 char pending_interface_name[IFNAMSIZ];
457 int pending_interface_type;
458 int p2p_group_idx;
459 unsigned int off_channel_freq;
460 struct wpabuf *pending_action_tx;
461 u8 pending_action_src[ETH_ALEN];
462 u8 pending_action_dst[ETH_ALEN];
463 u8 pending_action_bssid[ETH_ALEN];
464 unsigned int pending_action_freq;
465 int pending_action_without_roc;
466 unsigned int pending_listen_freq;
467 unsigned int pending_listen_duration;
468 enum {
469 NOT_P2P_GROUP_INTERFACE,
470 P2P_GROUP_INTERFACE_PENDING,
471 P2P_GROUP_INTERFACE_GO,
472 P2P_GROUP_INTERFACE_CLIENT
473 } p2p_group_interface;
474 struct p2p_group *p2p_group;
475 int p2p_long_listen;
476 char p2p_pin[10];
477 int p2p_wps_method;
478 u8 p2p_auth_invite[ETH_ALEN];
479 int p2p_sd_over_ctrl_iface;
480 int p2p_in_provisioning;
481 int pending_invite_ssid_id;
482 int show_group_started;
483 u8 go_dev_addr[ETH_ALEN];
484 int pending_pd_before_join;
485 u8 pending_join_iface_addr[ETH_ALEN];
486 u8 pending_join_dev_addr[ETH_ALEN];
487 int pending_join_wps_method;
488 unsigned int roc_waiting_drv_freq;
489 int force_long_sd;
490
491 /*
492 * Whether cross connection is disallowed by the AP to which this
493 * interface is associated (only valid if there is an association).
494 */
495 int cross_connect_disallowed;
496
497 /*
498 * Whether this P2P group is configured to use cross connection (only
499 * valid if this is P2P GO interface). The actual cross connect packet
500 * forwarding may not be configured depending on the uplink status.
501 */
502 int cross_connect_enabled;
503
504 /* Whether cross connection forwarding is in use at the moment. */
505 int cross_connect_in_use;
506
507 /*
508 * Uplink interface name for cross connection
509 */
510 char cross_connect_uplink[100];
511 #endif /* CONFIG_P2P */
512
513 struct wpa_ssid *bgscan_ssid;
514 const struct bgscan_ops *bgscan;
515 void *bgscan_priv;
516
517 int connect_without_scan;
518
519 int after_wps;
520 unsigned int wps_freq;
521 int wps_fragment_size;
522 };
523
524
525 /* wpa_supplicant.c */
526 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
527
528 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
529
530 const char * wpa_supplicant_state_txt(enum wpa_states state);
531 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
532 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
533 struct wpa_bss *bss, struct wpa_ssid *ssid,
534 u8 *wpa_ie, size_t *wpa_ie_len);
535 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
536 struct wpa_bss *bss,
537 struct wpa_ssid *ssid);
538 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
539 struct wpa_ssid *ssid);
540 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
541 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
542 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
543 int sec, int usec);
544 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
545 enum wpa_states state);
546 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
547 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
548 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
549 int reason_code);
550 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
551 int reason_code);
552
553 void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
554 struct wpa_ssid *ssid);
555 void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
556 struct wpa_ssid *ssid);
557 void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
558 struct wpa_ssid *ssid);
559 int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
560 int ap_scan);
561 int wpa_supplicant_set_debug_params(struct wpa_global *global,
562 int debug_level, int debug_timestamp,
563 int debug_show_keys);
564
565 void wpa_show_license(void);
566
567 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
568 struct wpa_interface *iface);
569 int wpa_supplicant_remove_iface(struct wpa_global *global,
570 struct wpa_supplicant *wpa_s);
571 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
572 const char *ifname);
573 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
574 int wpa_supplicant_run(struct wpa_global *global);
575 void wpa_supplicant_deinit(struct wpa_global *global);
576
577 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
578 struct wpa_ssid *ssid);
579 void wpa_supplicant_terminate_proc(struct wpa_global *global);
580 void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
581 const u8 *buf, size_t len);
582 enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
583 enum wpa_cipher cipher_suite2driver(int cipher);
584 void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
585 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
586
587 /* events.c */
588 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
589 void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
590 struct wpa_bss *selected,
591 struct wpa_ssid *ssid);
592
593 /* eap_register.c */
594 int eap_register_methods(void);
595
596 #endif /* WPA_SUPPLICANT_I_H */