]> git.ipfire.org Git - thirdparty/hostap.git/blame - wpa_supplicant/wpa_supplicant_i.h
P2P: Fix country string mismatch validation off-by-one offset
[thirdparty/hostap.git] / wpa_supplicant / wpa_supplicant_i.h
CommitLineData
6fc6879b
JM
1/*
2 * wpa_supplicant - Internal definitions
207ef3fb 3 * Copyright (c) 2003-2010, Jouni Malinen <j@w1.fi>
6fc6879b
JM
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
83922c2d 18#include "utils/list.h"
2d5b792d 19#include "common/defs.h"
6fc6879b 20
7e5ba1b9
JM
21extern const char *wpa_supplicant_version;
22extern const char *wpa_supplicant_license;
23#ifndef CONFIG_NO_STDOUT_DEBUG
24extern const char *wpa_supplicant_full_license1;
25extern const char *wpa_supplicant_full_license2;
26extern const char *wpa_supplicant_full_license3;
27extern const char *wpa_supplicant_full_license4;
28extern const char *wpa_supplicant_full_license5;
29#endif /* CONFIG_NO_STDOUT_DEBUG */
30
6fc6879b
JM
31struct wpa_sm;
32struct wpa_supplicant;
11ef8d35 33struct ibss_rsn;
8d923a4a 34struct scan_info;
6fa81a3b 35struct wpa_bss;
64e58f51 36struct wpa_scan_results;
6fc6879b
JM
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 */
43struct ctrl_iface_priv;
44struct ctrl_iface_global_priv;
8ddef94b 45struct wpas_dbus_priv;
6fc6879b
JM
46
47/**
48 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
49 */
50struct 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 */
106struct 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;
daa70d49
SL
160
161 /**
162 * wpa_debug_syslog - Enable log output through syslog
163 */
164 int wpa_debug_syslog;
d27df100
JM
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;
6fc6879b
JM
183};
184
b22128ef
JM
185struct p2p_srv_bonjour {
186 struct dl_list list;
187 struct wpabuf *query;
188 struct wpabuf *resp;
189};
190
191struct p2p_srv_upnp {
192 struct dl_list list;
193 u8 version;
194 char *service;
195};
196
6fc6879b
JM
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 */
203struct wpa_global {
204 struct wpa_supplicant *ifaces;
205 struct wpa_params params;
206 struct ctrl_iface_global_priv *ctrl_iface;
8ddef94b 207 struct wpas_dbus_priv *dbus;
ac305589
JM
208 void **drv_priv;
209 size_t drv_count;
207ef3fb 210 struct os_time suspend_time;
b22128ef
JM
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;
6fc6879b
JM
217};
218
219
220struct wpa_client_mlme {
221#ifdef CONFIG_CLIENT_MLME
222 enum {
223 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
224 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
225 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
226 } state;
227 u8 prev_bssid[ETH_ALEN];
228 u8 ssid[32];
229 size_t ssid_len;
230 u16 aid;
231 u16 ap_capab, capab;
232 u8 *extra_ie; /* to be added to the end of AssocReq */
233 size_t extra_ie_len;
234 u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
235 size_t extra_probe_ie_len;
71934751 236 enum wpa_key_mgmt key_mgmt;
6fc6879b
JM
237
238 /* The last AssocReq/Resp IEs */
239 u8 *assocreq_ies, *assocresp_ies;
240 size_t assocreq_ies_len, assocresp_ies_len;
241
242 int auth_tries, assoc_tries;
243
244 unsigned int ssid_set:1;
245 unsigned int bssid_set:1;
246 unsigned int prev_bssid_set:1;
247 unsigned int authenticated:1;
248 unsigned int associated:1;
249 unsigned int probereq_poll:1;
250 unsigned int use_protection:1;
251 unsigned int create_ibss:1;
252 unsigned int mixed_cell:1;
253 unsigned int wmm_enabled:1;
254
255 struct os_time last_probe;
256
abd9fafa
JM
257 unsigned int auth_algs; /* bitfield of allowed auth algs
258 * (WPA_AUTH_ALG_*) */
6fc6879b
JM
259 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
260 int auth_transaction;
261
262 struct os_time ibss_join_req;
263 u8 *probe_resp; /* ProbeResp template for IBSS */
264 size_t probe_resp_len;
265 u32 supp_rates_bits;
266
267 int wmm_last_param_set;
268
269 int sta_scanning;
270 int scan_hw_mode_idx;
271 int scan_channel_idx;
272 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
273 struct os_time last_scan_completed;
274 int scan_oper_channel;
275 int scan_oper_freq;
276 int scan_oper_phymode;
277 u8 scan_ssid[32];
278 size_t scan_ssid_len;
279 int scan_skip_11b;
d009a9da 280 int *scan_freqs;
6fc6879b
JM
281
282 struct ieee80211_sta_bss *sta_bss_list;
283#define STA_HASH_SIZE 256
284#define STA_HASH(sta) (sta[5])
285 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
286
287 int cts_protect_erp_frames;
288
71934751 289 enum hostapd_hw_mode phymode; /* current mode */
6caf9ca6 290 struct hostapd_hw_modes *modes;
6fc6879b
JM
291 size_t num_modes;
292 unsigned int hw_modes; /* bitfield of allowed hardware modes;
6caf9ca6 293 * (1 << HOSTAPD_MODE_*) */
6fc6879b 294 int num_curr_rates;
fb7842aa 295 int *curr_rates;
6fc6879b
JM
296 int freq; /* The current frequency in MHz */
297 int channel; /* The current IEEE 802.11 channel number */
298
299#ifdef CONFIG_IEEE80211R
300 u8 current_md[6];
301 u8 *ft_ies;
302 size_t ft_ies_len;
303#endif /* CONFIG_IEEE80211R */
304
c706d5aa
JM
305 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
306 int freq);
307 void *public_action_cb_ctx;
308
6fc6879b
JM
309#else /* CONFIG_CLIENT_MLME */
310 int dummy; /* to keep MSVC happy */
311#endif /* CONFIG_CLIENT_MLME */
312};
313
314/**
315 * struct wpa_supplicant - Internal data for wpa_supplicant interface
316 *
317 * This structure contains the internal data for core wpa_supplicant code. This
318 * should be only used directly from the core code. However, a pointer to this
319 * data is used from other files as an arbitrary context pointer in calls to
320 * core functions.
321 */
322struct wpa_supplicant {
323 struct wpa_global *global;
b22128ef 324 struct wpa_supplicant *parent;
6fc6879b
JM
325 struct wpa_supplicant *next;
326 struct l2_packet_data *l2;
327 struct l2_packet_data *l2_br;
328 unsigned char own_addr[ETH_ALEN];
329 char ifname[100];
330#ifdef CONFIG_CTRL_IFACE_DBUS
331 char *dbus_path;
332#endif /* CONFIG_CTRL_IFACE_DBUS */
8fc2fb56
WS
333#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
334 char *dbus_new_path;
335#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
6fc6879b
JM
336 char bridge_ifname[16];
337
338 char *confname;
339 struct wpa_config *conf;
340 int countermeasures;
341 os_time_t last_michael_mic_error;
342 u8 bssid[ETH_ALEN];
343 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
344 * field contains the targer BSSID. */
345 int reassociate; /* reassociation requested */
346 int disconnected; /* all connections disabled; i.e., do no reassociate
347 * before this has been cleared */
348 struct wpa_ssid *current_ssid;
8f770587 349 struct wpa_bss *current_bss;
6fc6879b 350 int ap_ies_from_associnfo;
4832ecd7 351 unsigned int assoc_freq;
6fc6879b
JM
352
353 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
354 int pairwise_cipher;
355 int group_cipher;
356 int key_mgmt;
357 int mgmt_group_cipher;
358
359 void *drv_priv; /* private data used by driver_ops */
8a5ab9f5 360 void *global_drv_priv;
6fc6879b
JM
361
362 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
363 * NULL = not yet initialized (start
ba2a573c
JM
364 * with wildcard SSID)
365 * WILDCARD_SSID_SCAN = wildcard
6fc6879b
JM
366 * SSID was used in the previous scan
367 */
ba2a573c 368#define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
6fc6879b 369
64e58f51
JM
370 void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
371 struct wpa_scan_results *scan_res);
83922c2d 372 struct dl_list bss; /* struct wpa_bss::list */
d4bf8f13 373 struct dl_list bss_id; /* struct wpa_bss::list_id */
83922c2d
JM
374 size_t num_bss;
375 unsigned int bss_update_idx;
376 unsigned int bss_next_id;
6fc6879b
JM
377
378 struct wpa_driver_ops *driver;
379 int interface_removed; /* whether the network interface has been
380 * removed */
381 struct wpa_sm *wpa;
382 struct eapol_sm *eapol;
383
384 struct ctrl_iface_priv *ctrl_iface;
385
71934751 386 enum wpa_states wpa_state;
cb8564b1 387 int scanning;
6fc6879b
JM
388 int new_connection;
389 int reassociated_connection;
390
391 int eapol_received; /* number of EAPOL packets received after the
392 * previous association event */
393
394 struct scard_data *scard;
395
396 unsigned char last_eapol_src[ETH_ALEN];
397
398 int keys_cleared;
399
400 struct wpa_blacklist *blacklist;
401
402 int scan_req; /* manual scan request; this forces a scan even if there
403 * are no enabled networks in the configuration */
a6099152 404 int scan_runs; /* number of scan runs since WPS was started */
6fc6879b
JM
405
406 struct wpa_client_mlme mlme;
c2a04078 407 unsigned int drv_flags;
80bc75f1 408 int max_scan_ssids;
814782b9 409 unsigned int max_remain_on_chan;
46690a3b
JM
410
411 int pending_mic_error_report;
412 int pending_mic_error_pairwise;
413 int mic_errors_seen; /* Michael MIC errors with the current PTK */
116654ce
JM
414
415 struct wps_context *wps;
a6099152 416 int wps_success; /* WPS success event received */
e9bcfebf 417 struct wps_er *wps_er;
a6099152 418 int blacklist_cleared;
11ef8d35 419
1ff73338
JM
420 struct wpabuf *pending_eapol_rx;
421 struct os_time pending_eapol_rx_time;
422 u8 pending_eapol_rx_src[ETH_ALEN];
423
11ef8d35 424 struct ibss_rsn *ibss_rsn;
c2a04078
JM
425
426#ifdef CONFIG_SME
427 struct {
428 u8 ssid[32];
429 size_t ssid_len;
430 int freq;
b22128ef 431 u8 assoc_req_ie[200];
c2a04078
JM
432 size_t assoc_req_ie_len;
433 int mfp;
434 int ft_used;
435 u8 mobility_domain[2];
436 u8 *ft_ies;
437 size_t ft_ies_len;
62fa124c
JM
438 u8 prev_bssid[ETH_ALEN];
439 int prev_bssid_set;
62c72d72 440 int auth_alg;
c2a04078
JM
441 } sme;
442#endif /* CONFIG_SME */
2d5b792d
JM
443
444#ifdef CONFIG_AP
445 struct hostapd_iface *ap_iface;
4b768ed0
JM
446 void (*ap_configured_cb)(void *ctx, void *data);
447 void *ap_configured_cb_ctx;
448 void *ap_configured_cb_data;
2d5b792d 449#endif /* CONFIG_AP */
60b94c98 450
b22128ef
JM
451#ifdef CONFIG_P2P
452 struct p2p_go_neg_results *go_params;
453 int create_p2p_iface;
454 u8 pending_interface_addr[ETH_ALEN];
455 char pending_interface_name[IFNAMSIZ];
456 int pending_interface_type;
457 int p2p_group_idx;
458 unsigned int off_channel_freq;
459 struct wpabuf *pending_action_tx;
460 u8 pending_action_src[ETH_ALEN];
461 u8 pending_action_dst[ETH_ALEN];
462 u8 pending_action_bssid[ETH_ALEN];
463 unsigned int pending_action_freq;
464 int pending_action_without_roc;
465 unsigned int pending_listen_freq;
466 unsigned int pending_listen_duration;
467 enum {
468 NOT_P2P_GROUP_INTERFACE,
469 P2P_GROUP_INTERFACE_PENDING,
470 P2P_GROUP_INTERFACE_GO,
471 P2P_GROUP_INTERFACE_CLIENT
472 } p2p_group_interface;
473 struct p2p_group *p2p_group;
474 int p2p_long_listen;
475 char p2p_pin[10];
3c5126a4 476 int p2p_wps_method;
108def93 477 u8 p2p_auth_invite[ETH_ALEN];
b22128ef
JM
478 int p2p_sd_over_ctrl_iface;
479 int p2p_in_provisioning;
480 int pending_invite_ssid_id;
481 int show_group_started;
482 u8 go_dev_addr[ETH_ALEN];
483 int pending_pd_before_join;
484 u8 pending_join_iface_addr[ETH_ALEN];
485 u8 pending_join_dev_addr[ETH_ALEN];
486 int pending_join_wps_method;
07a30a66 487 unsigned int roc_waiting_drv_freq;
b22128ef
JM
488#endif /* CONFIG_P2P */
489
60b94c98
JM
490 struct wpa_ssid *bgscan_ssid;
491 const struct bgscan_ops *bgscan;
492 void *bgscan_priv;
17a4734d 493
8cd82735
JM
494 int connect_without_scan;
495
17a4734d
JM
496 int after_wps;
497 unsigned int wps_freq;
42f50264 498 int wps_fragment_size;
6fc6879b
JM
499};
500
501
502/* wpa_supplicant.c */
0194fedb
JB
503int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
504
6fc6879b
JM
505int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
506
71934751 507const char * wpa_supplicant_state_txt(enum wpa_states state);
6fc6879b
JM
508int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
509int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
6fa81a3b 510 struct wpa_bss *bss, struct wpa_ssid *ssid,
6fc6879b
JM
511 u8 *wpa_ie, size_t *wpa_ie_len);
512void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
6fa81a3b 513 struct wpa_bss *bss,
6fc6879b
JM
514 struct wpa_ssid *ssid);
515void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
516 struct wpa_ssid *ssid);
517void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
6fc6879b
JM
518void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
519void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
520 int sec, int usec);
71934751
JM
521void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
522 enum wpa_states state);
6fc6879b
JM
523struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
524void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
525void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
526 int reason_code);
527void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
528 int reason_code);
529
86b89452
WS
530void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
531 struct wpa_ssid *ssid);
532void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
533 struct wpa_ssid *ssid);
534void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
535 struct wpa_ssid *ssid);
536int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
537 int ap_scan);
538int wpa_supplicant_set_debug_params(struct wpa_global *global,
539 int debug_level, int debug_timestamp,
540 int debug_show_keys);
541
6fc6879b
JM
542void wpa_show_license(void);
543
544struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
545 struct wpa_interface *iface);
546int wpa_supplicant_remove_iface(struct wpa_global *global,
547 struct wpa_supplicant *wpa_s);
548struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
549 const char *ifname);
550struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
551int wpa_supplicant_run(struct wpa_global *global);
552void wpa_supplicant_deinit(struct wpa_global *global);
553
554int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
555 struct wpa_ssid *ssid);
1a1bf008 556void wpa_supplicant_terminate_proc(struct wpa_global *global);
a8e0505b
JM
557void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
558 const u8 *buf, size_t len);
508545f3
JM
559enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
560enum wpa_cipher cipher_suite2driver(int cipher);
611aea7d 561void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
b22128ef 562void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
6fc6879b 563
6fc6879b
JM
564/* events.c */
565void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
86d4f806
JM
566void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
567 struct wpa_bss *selected,
568 struct wpa_ssid *ssid);
6fc6879b 569
12760815
JM
570/* eap_register.c */
571int eap_register_methods(void);
572
6fc6879b 573#endif /* WPA_SUPPLICANT_I_H */