]> git.ipfire.org Git - thirdparty/hostap.git/blame - wpa_supplicant/wpa_supplicant_i.h
Replace hostapd_notif_new_sta() with new driver event, EVENT_NEW_STA
[thirdparty/hostap.git] / wpa_supplicant / wpa_supplicant_i.h
CommitLineData
6fc6879b
JM
1/*
2 * wpa_supplicant - Internal definitions
83922c2d 3 * Copyright (c) 2003-2009, 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;
6fc6879b
JM
36
37/*
38 * Forward declarations of private structures used within the ctrl_iface
39 * backends. Other parts of wpa_supplicant do not have access to data stored in
40 * these structures.
41 */
42struct ctrl_iface_priv;
43struct ctrl_iface_global_priv;
8ddef94b 44struct wpas_dbus_priv;
6fc6879b
JM
45
46/**
47 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
48 */
49struct wpa_interface {
50 /**
51 * confname - Configuration name (file or profile) name
52 *
53 * This can also be %NULL when a configuration file is not used. In
54 * that case, ctrl_interface must be set to allow the interface to be
55 * configured.
56 */
57 const char *confname;
58
59 /**
60 * ctrl_interface - Control interface parameter
61 *
62 * If a configuration file is not used, this variable can be used to
63 * set the ctrl_interface parameter that would have otherwise been read
64 * from the configuration file. If both confname and ctrl_interface are
65 * set, ctrl_interface is used to override the value from configuration
66 * file.
67 */
68 const char *ctrl_interface;
69
70 /**
71 * driver - Driver interface name, or %NULL to use the default driver
72 */
73 const char *driver;
74
75 /**
76 * driver_param - Driver interface parameters
77 *
78 * If a configuration file is not used, this variable can be used to
79 * set the driver_param parameters that would have otherwise been read
80 * from the configuration file. If both confname and driver_param are
81 * set, driver_param is used to override the value from configuration
82 * file.
83 */
84 const char *driver_param;
85
86 /**
87 * ifname - Interface name
88 */
89 const char *ifname;
90
91 /**
92 * bridge_ifname - Optional bridge interface name
93 *
94 * If the driver interface (ifname) is included in a Linux bridge
95 * device, the bridge interface may need to be used for receiving EAPOL
96 * frames. This can be enabled by setting this variable to enable
97 * receiving of EAPOL frames from an additional interface.
98 */
99 const char *bridge_ifname;
100};
101
102/**
103 * struct wpa_params - Parameters for wpa_supplicant_init()
104 */
105struct wpa_params {
106 /**
107 * daemonize - Run %wpa_supplicant in the background
108 */
109 int daemonize;
110
111 /**
112 * wait_for_monitor - Wait for a monitor program before starting
113 */
114 int wait_for_monitor;
115
116 /**
117 * pid_file - Path to a PID (process ID) file
118 *
119 * If this and daemonize are set, process ID of the background process
120 * will be written to the specified file.
121 */
122 char *pid_file;
123
124 /**
125 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
126 */
127 int wpa_debug_level;
128
129 /**
130 * wpa_debug_show_keys - Whether keying material is included in debug
131 *
132 * This parameter can be used to allow keying material to be included
133 * in debug messages. This is a security risk and this option should
134 * not be enabled in normal configuration. If needed during
135 * development or while troubleshooting, this option can provide more
136 * details for figuring out what is happening.
137 */
138 int wpa_debug_show_keys;
139
140 /**
141 * wpa_debug_timestamp - Whether to include timestamp in debug messages
142 */
143 int wpa_debug_timestamp;
144
145 /**
146 * ctrl_interface - Global ctrl_iface path/parameter
147 */
148 char *ctrl_interface;
149
150 /**
151 * dbus_ctrl_interface - Enable the DBus control interface
152 */
153 int dbus_ctrl_interface;
154
155 /**
156 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
157 */
158 const char *wpa_debug_file_path;
daa70d49
SL
159
160 /**
161 * wpa_debug_syslog - Enable log output through syslog
162 */
163 int wpa_debug_syslog;
d27df100
JM
164
165 /**
166 * override_driver - Optional driver parameter override
167 *
168 * This parameter can be used to override the driver parameter in
169 * dynamic interface addition to force a specific driver wrapper to be
170 * used instead.
171 */
172 char *override_driver;
173
174 /**
175 * override_ctrl_interface - Optional ctrl_interface override
176 *
177 * This parameter can be used to override the ctrl_interface parameter
178 * in dynamic interface addition to force a control interface to be
179 * created.
180 */
181 char *override_ctrl_interface;
6fc6879b
JM
182};
183
184/**
185 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
186 *
187 * This structure is initialized by calling wpa_supplicant_init() when starting
188 * %wpa_supplicant.
189 */
190struct wpa_global {
191 struct wpa_supplicant *ifaces;
192 struct wpa_params params;
193 struct ctrl_iface_global_priv *ctrl_iface;
8ddef94b 194 struct wpas_dbus_priv *dbus;
ac305589
JM
195 void **drv_priv;
196 size_t drv_count;
6fc6879b
JM
197};
198
199
200struct wpa_client_mlme {
201#ifdef CONFIG_CLIENT_MLME
202 enum {
203 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
204 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
205 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
206 } state;
207 u8 prev_bssid[ETH_ALEN];
208 u8 ssid[32];
209 size_t ssid_len;
210 u16 aid;
211 u16 ap_capab, capab;
212 u8 *extra_ie; /* to be added to the end of AssocReq */
213 size_t extra_ie_len;
214 u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
215 size_t extra_probe_ie_len;
71934751 216 enum wpa_key_mgmt key_mgmt;
6fc6879b
JM
217
218 /* The last AssocReq/Resp IEs */
219 u8 *assocreq_ies, *assocresp_ies;
220 size_t assocreq_ies_len, assocresp_ies_len;
221
222 int auth_tries, assoc_tries;
223
224 unsigned int ssid_set:1;
225 unsigned int bssid_set:1;
226 unsigned int prev_bssid_set:1;
227 unsigned int authenticated:1;
228 unsigned int associated:1;
229 unsigned int probereq_poll:1;
230 unsigned int use_protection:1;
231 unsigned int create_ibss:1;
232 unsigned int mixed_cell:1;
233 unsigned int wmm_enabled:1;
234
235 struct os_time last_probe;
236
237#define IEEE80211_AUTH_ALG_OPEN BIT(0)
238#define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
239#define IEEE80211_AUTH_ALG_LEAP BIT(2)
240 unsigned int auth_algs; /* bitfield of allowed auth algs */
241 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
242 int auth_transaction;
243
244 struct os_time ibss_join_req;
245 u8 *probe_resp; /* ProbeResp template for IBSS */
246 size_t probe_resp_len;
247 u32 supp_rates_bits;
248
249 int wmm_last_param_set;
250
251 int sta_scanning;
252 int scan_hw_mode_idx;
253 int scan_channel_idx;
254 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
255 struct os_time last_scan_completed;
256 int scan_oper_channel;
257 int scan_oper_freq;
258 int scan_oper_phymode;
259 u8 scan_ssid[32];
260 size_t scan_ssid_len;
261 int scan_skip_11b;
d009a9da 262 int *scan_freqs;
6fc6879b
JM
263
264 struct ieee80211_sta_bss *sta_bss_list;
265#define STA_HASH_SIZE 256
266#define STA_HASH(sta) (sta[5])
267 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
268
269 int cts_protect_erp_frames;
270
71934751 271 enum hostapd_hw_mode phymode; /* current mode */
6caf9ca6 272 struct hostapd_hw_modes *modes;
6fc6879b
JM
273 size_t num_modes;
274 unsigned int hw_modes; /* bitfield of allowed hardware modes;
6caf9ca6 275 * (1 << HOSTAPD_MODE_*) */
6fc6879b 276 int num_curr_rates;
fb7842aa 277 int *curr_rates;
6fc6879b
JM
278 int freq; /* The current frequency in MHz */
279 int channel; /* The current IEEE 802.11 channel number */
280
281#ifdef CONFIG_IEEE80211R
282 u8 current_md[6];
283 u8 *ft_ies;
284 size_t ft_ies_len;
285#endif /* CONFIG_IEEE80211R */
286
287#else /* CONFIG_CLIENT_MLME */
288 int dummy; /* to keep MSVC happy */
289#endif /* CONFIG_CLIENT_MLME */
290};
291
292/**
293 * struct wpa_supplicant - Internal data for wpa_supplicant interface
294 *
295 * This structure contains the internal data for core wpa_supplicant code. This
296 * should be only used directly from the core code. However, a pointer to this
297 * data is used from other files as an arbitrary context pointer in calls to
298 * core functions.
299 */
300struct wpa_supplicant {
301 struct wpa_global *global;
302 struct wpa_supplicant *next;
303 struct l2_packet_data *l2;
304 struct l2_packet_data *l2_br;
305 unsigned char own_addr[ETH_ALEN];
306 char ifname[100];
307#ifdef CONFIG_CTRL_IFACE_DBUS
308 char *dbus_path;
309#endif /* CONFIG_CTRL_IFACE_DBUS */
8fc2fb56
WS
310#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
311 char *dbus_new_path;
312#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
6fc6879b
JM
313 char bridge_ifname[16];
314
315 char *confname;
316 struct wpa_config *conf;
317 int countermeasures;
318 os_time_t last_michael_mic_error;
319 u8 bssid[ETH_ALEN];
320 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
321 * field contains the targer BSSID. */
322 int reassociate; /* reassociation requested */
323 int disconnected; /* all connections disabled; i.e., do no reassociate
324 * before this has been cleared */
325 struct wpa_ssid *current_ssid;
8f770587 326 struct wpa_bss *current_bss;
6fc6879b 327 int ap_ies_from_associnfo;
4832ecd7 328 unsigned int assoc_freq;
6fc6879b
JM
329
330 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
331 int pairwise_cipher;
332 int group_cipher;
333 int key_mgmt;
334 int mgmt_group_cipher;
335
336 void *drv_priv; /* private data used by driver_ops */
8a5ab9f5 337 void *global_drv_priv;
6fc6879b
JM
338
339 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
340 * NULL = not yet initialized (start
ba2a573c
JM
341 * with wildcard SSID)
342 * WILDCARD_SSID_SCAN = wildcard
6fc6879b
JM
343 * SSID was used in the previous scan
344 */
ba2a573c 345#define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
6fc6879b 346
83922c2d 347 struct dl_list bss; /* struct wpa_bss::list */
d4bf8f13 348 struct dl_list bss_id; /* struct wpa_bss::list_id */
83922c2d
JM
349 size_t num_bss;
350 unsigned int bss_update_idx;
351 unsigned int bss_next_id;
6fc6879b
JM
352
353 struct wpa_driver_ops *driver;
354 int interface_removed; /* whether the network interface has been
355 * removed */
356 struct wpa_sm *wpa;
357 struct eapol_sm *eapol;
358
359 struct ctrl_iface_priv *ctrl_iface;
360
71934751 361 enum wpa_states wpa_state;
cb8564b1 362 int scanning;
6fc6879b
JM
363 int new_connection;
364 int reassociated_connection;
365
366 int eapol_received; /* number of EAPOL packets received after the
367 * previous association event */
368
369 struct scard_data *scard;
370
371 unsigned char last_eapol_src[ETH_ALEN];
372
373 int keys_cleared;
374
375 struct wpa_blacklist *blacklist;
376
377 int scan_req; /* manual scan request; this forces a scan even if there
378 * are no enabled networks in the configuration */
379 int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
380 * results without a new scan request; this is used
381 * to speed up the first association if the driver
382 * has already available scan results. */
a6099152 383 int scan_runs; /* number of scan runs since WPS was started */
6fc6879b
JM
384
385 struct wpa_client_mlme mlme;
c2a04078 386 unsigned int drv_flags;
80bc75f1 387 int max_scan_ssids;
46690a3b
JM
388
389 int pending_mic_error_report;
390 int pending_mic_error_pairwise;
391 int mic_errors_seen; /* Michael MIC errors with the current PTK */
116654ce
JM
392
393 struct wps_context *wps;
a6099152 394 int wps_success; /* WPS success event received */
e9bcfebf 395 struct wps_er *wps_er;
a6099152 396 int blacklist_cleared;
11ef8d35 397
1ff73338
JM
398 struct wpabuf *pending_eapol_rx;
399 struct os_time pending_eapol_rx_time;
400 u8 pending_eapol_rx_src[ETH_ALEN];
401
11ef8d35 402 struct ibss_rsn *ibss_rsn;
c2a04078
JM
403
404#ifdef CONFIG_SME
405 struct {
406 u8 ssid[32];
407 size_t ssid_len;
408 int freq;
409 u8 assoc_req_ie[80];
410 size_t assoc_req_ie_len;
411 int mfp;
412 int ft_used;
413 u8 mobility_domain[2];
414 u8 *ft_ies;
415 size_t ft_ies_len;
62fa124c
JM
416 u8 prev_bssid[ETH_ALEN];
417 int prev_bssid_set;
c2a04078
JM
418 } sme;
419#endif /* CONFIG_SME */
2d5b792d
JM
420
421#ifdef CONFIG_AP
422 struct hostapd_iface *ap_iface;
423#endif /* CONFIG_AP */
60b94c98
JM
424
425 struct wpa_ssid *bgscan_ssid;
426 const struct bgscan_ops *bgscan;
427 void *bgscan_priv;
6fc6879b
JM
428};
429
430
431/* wpa_supplicant.c */
0194fedb
JB
432int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
433
6fc6879b
JM
434int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
435
71934751 436const char * wpa_supplicant_state_txt(enum wpa_states state);
6fc6879b
JM
437int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
438int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
6fa81a3b 439 struct wpa_bss *bss, struct wpa_ssid *ssid,
6fc6879b
JM
440 u8 *wpa_ie, size_t *wpa_ie_len);
441void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
6fa81a3b 442 struct wpa_bss *bss,
6fc6879b
JM
443 struct wpa_ssid *ssid);
444void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
445 struct wpa_ssid *ssid);
446void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
a1fd2ce5
JM
447struct wpa_scan_results *
448wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s,
449 struct scan_info *info, int new_scan);
450int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s);
6fc6879b
JM
451void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
452void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
453 int sec, int usec);
71934751
JM
454void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
455 enum wpa_states state);
6fc6879b
JM
456struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
457void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
458void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
459 int reason_code);
460void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
461 int reason_code);
462
86b89452
WS
463void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
464 struct wpa_ssid *ssid);
465void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
466 struct wpa_ssid *ssid);
467void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
468 struct wpa_ssid *ssid);
469int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
470 int ap_scan);
471int wpa_supplicant_set_debug_params(struct wpa_global *global,
472 int debug_level, int debug_timestamp,
473 int debug_show_keys);
474
6fc6879b
JM
475void wpa_show_license(void);
476
477struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
478 struct wpa_interface *iface);
479int wpa_supplicant_remove_iface(struct wpa_global *global,
480 struct wpa_supplicant *wpa_s);
481struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
482 const char *ifname);
483struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
484int wpa_supplicant_run(struct wpa_global *global);
485void wpa_supplicant_deinit(struct wpa_global *global);
486
487int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
488 struct wpa_ssid *ssid);
1a1bf008 489void wpa_supplicant_terminate_proc(struct wpa_global *global);
6fc6879b
JM
490
491/* scan.c */
4f34d51a 492int wpa_supplicant_enabled_networks(struct wpa_config *conf);
6fc6879b
JM
493void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
494void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
cb8564b1
DW
495void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
496 int scanning);
60b94c98
JM
497struct wpa_driver_scan_params;
498int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s,
499 struct wpa_driver_scan_params *params);
6fc6879b
JM
500
501/* events.c */
502void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
503
12760815
JM
504/* eap_register.c */
505int eap_register_methods(void);
506
6fc6879b 507#endif /* WPA_SUPPLICANT_I_H */