xref: /freebsd/contrib/wpa/src/ap/hostapd.h (revision 85732ac8bccbc0adcf5a261ea1ffec8ca7b3a92d)
1e28a4053SRui Paulo /*
2e28a4053SRui Paulo  * hostapd / Initialization and configuration
35b9c547cSRui Paulo  * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi>
4e28a4053SRui Paulo  *
5f05cddf9SRui Paulo  * This software may be distributed under the terms of the BSD license.
6f05cddf9SRui Paulo  * See README for more details.
7e28a4053SRui Paulo  */
8e28a4053SRui Paulo 
9e28a4053SRui Paulo #ifndef HOSTAPD_H
10e28a4053SRui Paulo #define HOSTAPD_H
11e28a4053SRui Paulo 
12e28a4053SRui Paulo #include "common/defs.h"
135b9c547cSRui Paulo #include "utils/list.h"
14f05cddf9SRui Paulo #include "ap_config.h"
155b9c547cSRui Paulo #include "drivers/driver.h"
16e28a4053SRui Paulo 
17*85732ac8SCy Schubert #define OCE_STA_CFON_ENABLED(hapd) \
18*85732ac8SCy Schubert 	((hapd->conf->oce & OCE_STA_CFON) && \
19*85732ac8SCy Schubert 	 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_STA_CFON))
20*85732ac8SCy Schubert #define OCE_AP_ENABLED(hapd) \
21*85732ac8SCy Schubert 	((hapd->conf->oce & OCE_AP) && \
22*85732ac8SCy Schubert 	 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_AP))
23*85732ac8SCy Schubert 
24e28a4053SRui Paulo struct wpa_ctrl_dst;
25e28a4053SRui Paulo struct radius_server_data;
26e28a4053SRui Paulo struct upnp_wps_device_sm;
27e28a4053SRui Paulo struct hostapd_data;
28e28a4053SRui Paulo struct sta_info;
29e28a4053SRui Paulo struct ieee80211_ht_capabilities;
30e28a4053SRui Paulo struct full_dynamic_vlan;
31f05cddf9SRui Paulo enum wps_event;
32f05cddf9SRui Paulo union wps_event_data;
335b9c547cSRui Paulo #ifdef CONFIG_MESH
345b9c547cSRui Paulo struct mesh_conf;
355b9c547cSRui Paulo #endif /* CONFIG_MESH */
36f05cddf9SRui Paulo 
37f05cddf9SRui Paulo struct hostapd_iface;
38f05cddf9SRui Paulo 
39f05cddf9SRui Paulo struct hapd_interfaces {
40f05cddf9SRui Paulo 	int (*reload_config)(struct hostapd_iface *iface);
41f05cddf9SRui Paulo 	struct hostapd_config * (*config_read_cb)(const char *config_fname);
42f05cddf9SRui Paulo 	int (*ctrl_iface_init)(struct hostapd_data *hapd);
43f05cddf9SRui Paulo 	void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
44f05cddf9SRui Paulo 	int (*for_each_interface)(struct hapd_interfaces *interfaces,
45f05cddf9SRui Paulo 				  int (*cb)(struct hostapd_iface *iface,
46f05cddf9SRui Paulo 					    void *ctx), void *ctx);
47f05cddf9SRui Paulo 	int (*driver_init)(struct hostapd_iface *iface);
48f05cddf9SRui Paulo 
49f05cddf9SRui Paulo 	size_t count;
50f05cddf9SRui Paulo 	int global_ctrl_sock;
51780fb4a2SCy Schubert 	struct dl_list global_ctrl_dst;
52f05cddf9SRui Paulo 	char *global_iface_path;
53f05cddf9SRui Paulo 	char *global_iface_name;
545b9c547cSRui Paulo #ifndef CONFIG_NATIVE_WINDOWS
555b9c547cSRui Paulo 	gid_t ctrl_iface_group;
565b9c547cSRui Paulo #endif /* CONFIG_NATIVE_WINDOWS */
57f05cddf9SRui Paulo 	struct hostapd_iface **iface;
585b9c547cSRui Paulo 
595b9c547cSRui Paulo 	size_t terminate_on_error;
60325151a3SRui Paulo #ifndef CONFIG_NO_VLAN
61325151a3SRui Paulo 	struct dynamic_iface *vlan_priv;
62325151a3SRui Paulo #endif /* CONFIG_NO_VLAN */
63*85732ac8SCy Schubert #ifdef CONFIG_ETH_P_OUI
64*85732ac8SCy Schubert 	struct dl_list eth_p_oui; /* OUI Extended EtherType handlers */
65*85732ac8SCy Schubert #endif /* CONFIG_ETH_P_OUI */
66780fb4a2SCy Schubert 	int eloop_initialized;
67*85732ac8SCy Schubert 
68*85732ac8SCy Schubert #ifdef CONFIG_DPP
69*85732ac8SCy Schubert 	int dpp_init_done;
70*85732ac8SCy Schubert 	struct dl_list dpp_bootstrap; /* struct dpp_bootstrap_info */
71*85732ac8SCy Schubert 	struct dl_list dpp_configurator; /* struct dpp_configurator */
72*85732ac8SCy Schubert #endif /* CONFIG_DPP */
73f05cddf9SRui Paulo };
74f05cddf9SRui Paulo 
755b9c547cSRui Paulo enum hostapd_chan_status {
765b9c547cSRui Paulo 	HOSTAPD_CHAN_VALID = 0, /* channel is ready */
775b9c547cSRui Paulo 	HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */
785b9c547cSRui Paulo 	HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */
795b9c547cSRui Paulo };
80e28a4053SRui Paulo 
81e28a4053SRui Paulo struct hostapd_probereq_cb {
82f05cddf9SRui Paulo 	int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
83f05cddf9SRui Paulo 		  const u8 *ie, size_t ie_len, int ssi_signal);
84e28a4053SRui Paulo 	void *ctx;
85e28a4053SRui Paulo };
86e28a4053SRui Paulo 
87e28a4053SRui Paulo #define HOSTAPD_RATE_BASIC 0x00000001
88e28a4053SRui Paulo 
89e28a4053SRui Paulo struct hostapd_rate_data {
90e28a4053SRui Paulo 	int rate; /* rate in 100 kbps */
91e28a4053SRui Paulo 	int flags; /* HOSTAPD_RATE_ flags */
92e28a4053SRui Paulo };
93e28a4053SRui Paulo 
94e28a4053SRui Paulo struct hostapd_frame_info {
95*85732ac8SCy Schubert 	unsigned int freq;
96e28a4053SRui Paulo 	u32 channel;
97e28a4053SRui Paulo 	u32 datarate;
98f05cddf9SRui Paulo 	int ssi_signal; /* dBm */
99e28a4053SRui Paulo };
100e28a4053SRui Paulo 
1015b9c547cSRui Paulo enum wps_status {
1025b9c547cSRui Paulo 	WPS_STATUS_SUCCESS = 1,
1035b9c547cSRui Paulo 	WPS_STATUS_FAILURE
1045b9c547cSRui Paulo };
1055b9c547cSRui Paulo 
1065b9c547cSRui Paulo enum pbc_status {
1075b9c547cSRui Paulo 	WPS_PBC_STATUS_DISABLE,
1085b9c547cSRui Paulo 	WPS_PBC_STATUS_ACTIVE,
1095b9c547cSRui Paulo 	WPS_PBC_STATUS_TIMEOUT,
1105b9c547cSRui Paulo 	WPS_PBC_STATUS_OVERLAP
1115b9c547cSRui Paulo };
1125b9c547cSRui Paulo 
1135b9c547cSRui Paulo struct wps_stat {
1145b9c547cSRui Paulo 	enum wps_status status;
1155b9c547cSRui Paulo 	enum wps_error_indication failure_reason;
1165b9c547cSRui Paulo 	enum pbc_status pbc_status;
1175b9c547cSRui Paulo 	u8 peer_addr[ETH_ALEN];
1185b9c547cSRui Paulo };
1195b9c547cSRui Paulo 
120780fb4a2SCy Schubert struct hostapd_neighbor_entry {
121780fb4a2SCy Schubert 	struct dl_list list;
122780fb4a2SCy Schubert 	u8 bssid[ETH_ALEN];
123780fb4a2SCy Schubert 	struct wpa_ssid_value ssid;
124780fb4a2SCy Schubert 	struct wpabuf *nr;
125780fb4a2SCy Schubert 	struct wpabuf *lci;
126780fb4a2SCy Schubert 	struct wpabuf *civic;
127780fb4a2SCy Schubert 	/* LCI update time */
128780fb4a2SCy Schubert 	struct os_time lci_date;
129*85732ac8SCy Schubert 	int stationary;
130780fb4a2SCy Schubert };
131e28a4053SRui Paulo 
132e28a4053SRui Paulo /**
133e28a4053SRui Paulo  * struct hostapd_data - hostapd per-BSS data structure
134e28a4053SRui Paulo  */
135e28a4053SRui Paulo struct hostapd_data {
136e28a4053SRui Paulo 	struct hostapd_iface *iface;
137e28a4053SRui Paulo 	struct hostapd_config *iconf;
138e28a4053SRui Paulo 	struct hostapd_bss_config *conf;
139e28a4053SRui Paulo 	int interface_added; /* virtual interface added for this BSS */
1405b9c547cSRui Paulo 	unsigned int started:1;
1415b9c547cSRui Paulo 	unsigned int disabled:1;
1425b9c547cSRui Paulo 	unsigned int reenable_beacon:1;
143e28a4053SRui Paulo 
144e28a4053SRui Paulo 	u8 own_addr[ETH_ALEN];
145e28a4053SRui Paulo 
146e28a4053SRui Paulo 	int num_sta; /* number of entries in sta_list */
147e28a4053SRui Paulo 	struct sta_info *sta_list; /* STA info list head */
148e28a4053SRui Paulo #define STA_HASH_SIZE 256
149e28a4053SRui Paulo #define STA_HASH(sta) (sta[5])
150e28a4053SRui Paulo 	struct sta_info *sta_hash[STA_HASH_SIZE];
151e28a4053SRui Paulo 
152e28a4053SRui Paulo 	/*
153e28a4053SRui Paulo 	 * Bitfield for indicating which AIDs are allocated. Only AID values
154e28a4053SRui Paulo 	 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
155e28a4053SRui Paulo 	 * 1.
156e28a4053SRui Paulo 	 */
157e28a4053SRui Paulo #define AID_WORDS ((2008 + 31) / 32)
158e28a4053SRui Paulo 	u32 sta_aid[AID_WORDS];
159e28a4053SRui Paulo 
160e28a4053SRui Paulo 	const struct wpa_driver_ops *driver;
161e28a4053SRui Paulo 	void *drv_priv;
162e28a4053SRui Paulo 
163e28a4053SRui Paulo 	void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
164e28a4053SRui Paulo 				 struct sta_info *sta, int reassoc);
165e28a4053SRui Paulo 
166e28a4053SRui Paulo 	void *msg_ctx; /* ctx for wpa_msg() calls */
167f05cddf9SRui Paulo 	void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
168e28a4053SRui Paulo 
169e28a4053SRui Paulo 	struct radius_client_data *radius;
170780fb4a2SCy Schubert 	u64 acct_session_id;
171f05cddf9SRui Paulo 	struct radius_das_data *radius_das;
172e28a4053SRui Paulo 
173e28a4053SRui Paulo 	struct iapp_data *iapp;
174e28a4053SRui Paulo 
175e28a4053SRui Paulo 	struct hostapd_cached_radius_acl *acl_cache;
176e28a4053SRui Paulo 	struct hostapd_acl_query_data *acl_queries;
177e28a4053SRui Paulo 
178e28a4053SRui Paulo 	struct wpa_authenticator *wpa_auth;
179e28a4053SRui Paulo 	struct eapol_authenticator *eapol_auth;
180e28a4053SRui Paulo 
181e28a4053SRui Paulo 	struct rsn_preauth_interface *preauth_iface;
1825b9c547cSRui Paulo 	struct os_reltime michael_mic_failure;
183e28a4053SRui Paulo 	int michael_mic_failures;
184e28a4053SRui Paulo 	int tkip_countermeasures;
185e28a4053SRui Paulo 
186e28a4053SRui Paulo 	int ctrl_sock;
187780fb4a2SCy Schubert 	struct dl_list ctrl_dst;
188e28a4053SRui Paulo 
189e28a4053SRui Paulo 	void *ssl_ctx;
190e28a4053SRui Paulo 	void *eap_sim_db_priv;
191e28a4053SRui Paulo 	struct radius_server_data *radius_srv;
1925b9c547cSRui Paulo 	struct dl_list erp_keys; /* struct eap_server_erp_key */
193e28a4053SRui Paulo 
194e28a4053SRui Paulo 	int parameter_set_count;
195e28a4053SRui Paulo 
196f05cddf9SRui Paulo 	/* Time Advertisement */
197f05cddf9SRui Paulo 	u8 time_update_counter;
198f05cddf9SRui Paulo 	struct wpabuf *time_adv;
199f05cddf9SRui Paulo 
200e28a4053SRui Paulo #ifdef CONFIG_FULL_DYNAMIC_VLAN
201e28a4053SRui Paulo 	struct full_dynamic_vlan *full_dynamic_vlan;
202e28a4053SRui Paulo #endif /* CONFIG_FULL_DYNAMIC_VLAN */
203e28a4053SRui Paulo 
204e28a4053SRui Paulo 	struct l2_packet_data *l2;
205*85732ac8SCy Schubert 
206*85732ac8SCy Schubert #ifdef CONFIG_IEEE80211R_AP
207*85732ac8SCy Schubert 	struct dl_list l2_queue;
208*85732ac8SCy Schubert 	struct dl_list l2_oui_queue;
209*85732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_pull;
210*85732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_resp;
211*85732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_push;
212*85732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_sreq;
213*85732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_sresp;
214*85732ac8SCy Schubert #endif /* CONFIG_IEEE80211R_AP */
215*85732ac8SCy Schubert 
216e28a4053SRui Paulo 	struct wps_context *wps;
217e28a4053SRui Paulo 
218f05cddf9SRui Paulo 	int beacon_set_done;
219e28a4053SRui Paulo 	struct wpabuf *wps_beacon_ie;
220e28a4053SRui Paulo 	struct wpabuf *wps_probe_resp_ie;
221e28a4053SRui Paulo #ifdef CONFIG_WPS
222e28a4053SRui Paulo 	unsigned int ap_pin_failures;
223f05cddf9SRui Paulo 	unsigned int ap_pin_failures_consecutive;
224e28a4053SRui Paulo 	struct upnp_wps_device_sm *wps_upnp;
225e28a4053SRui Paulo 	unsigned int ap_pin_lockout_time;
2265b9c547cSRui Paulo 
2275b9c547cSRui Paulo 	struct wps_stat wps_stats;
228e28a4053SRui Paulo #endif /* CONFIG_WPS */
229e28a4053SRui Paulo 
230e28a4053SRui Paulo 	struct hostapd_probereq_cb *probereq_cb;
231e28a4053SRui Paulo 	size_t num_probereq_cb;
232e28a4053SRui Paulo 
233e28a4053SRui Paulo 	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
234e28a4053SRui Paulo 				 int freq);
235e28a4053SRui Paulo 	void *public_action_cb_ctx;
2365b9c547cSRui Paulo 	void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
2375b9c547cSRui Paulo 				  int freq);
2385b9c547cSRui Paulo 	void *public_action_cb2_ctx;
239e28a4053SRui Paulo 
240f05cddf9SRui Paulo 	int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
241f05cddf9SRui Paulo 				int freq);
242f05cddf9SRui Paulo 	void *vendor_action_cb_ctx;
243f05cddf9SRui Paulo 
244e28a4053SRui Paulo 	void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
245e28a4053SRui Paulo 				   const u8 *uuid_e);
246e28a4053SRui Paulo 	void *wps_reg_success_cb_ctx;
247f05cddf9SRui Paulo 
248f05cddf9SRui Paulo 	void (*wps_event_cb)(void *ctx, enum wps_event event,
249f05cddf9SRui Paulo 			     union wps_event_data *data);
250f05cddf9SRui Paulo 	void *wps_event_cb_ctx;
251f05cddf9SRui Paulo 
252f05cddf9SRui Paulo 	void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
253f05cddf9SRui Paulo 				  int authorized, const u8 *p2p_dev_addr);
254f05cddf9SRui Paulo 	void *sta_authorized_cb_ctx;
255f05cddf9SRui Paulo 
256f05cddf9SRui Paulo 	void (*setup_complete_cb)(void *ctx);
257f05cddf9SRui Paulo 	void *setup_complete_cb_ctx;
258f05cddf9SRui Paulo 
2595b9c547cSRui Paulo 	void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
2605b9c547cSRui Paulo 			   const u8 *p2p_dev_addr, const u8 *psk,
2615b9c547cSRui Paulo 			   size_t psk_len);
2625b9c547cSRui Paulo 	void *new_psk_cb_ctx;
2635b9c547cSRui Paulo 
2645b9c547cSRui Paulo 	/* channel switch parameters */
2655b9c547cSRui Paulo 	struct hostapd_freq_params cs_freq_params;
2665b9c547cSRui Paulo 	u8 cs_count;
2675b9c547cSRui Paulo 	int cs_block_tx;
2685b9c547cSRui Paulo 	unsigned int cs_c_off_beacon;
2695b9c547cSRui Paulo 	unsigned int cs_c_off_proberesp;
2705b9c547cSRui Paulo 	int csa_in_progress;
271780fb4a2SCy Schubert 	unsigned int cs_c_off_ecsa_beacon;
272780fb4a2SCy Schubert 	unsigned int cs_c_off_ecsa_proberesp;
2735b9c547cSRui Paulo 
274f05cddf9SRui Paulo #ifdef CONFIG_P2P
275f05cddf9SRui Paulo 	struct p2p_data *p2p;
276f05cddf9SRui Paulo 	struct p2p_group *p2p_group;
277f05cddf9SRui Paulo 	struct wpabuf *p2p_beacon_ie;
278f05cddf9SRui Paulo 	struct wpabuf *p2p_probe_resp_ie;
279f05cddf9SRui Paulo 
280f05cddf9SRui Paulo 	/* Number of non-P2P association stations */
281f05cddf9SRui Paulo 	int num_sta_no_p2p;
282f05cddf9SRui Paulo 
283f05cddf9SRui Paulo 	/* Periodic NoA (used only when no non-P2P clients in the group) */
284f05cddf9SRui Paulo 	int noa_enabled;
285f05cddf9SRui Paulo 	int noa_start;
286f05cddf9SRui Paulo 	int noa_duration;
287f05cddf9SRui Paulo #endif /* CONFIG_P2P */
2885b9c547cSRui Paulo #ifdef CONFIG_PROXYARP
2895b9c547cSRui Paulo 	struct l2_packet_data *sock_dhcp;
2905b9c547cSRui Paulo 	struct l2_packet_data *sock_ndisc;
2915b9c547cSRui Paulo #endif /* CONFIG_PROXYARP */
2925b9c547cSRui Paulo #ifdef CONFIG_MESH
2935b9c547cSRui Paulo 	int num_plinks;
2945b9c547cSRui Paulo 	int max_plinks;
295780fb4a2SCy Schubert 	void (*mesh_sta_free_cb)(struct hostapd_data *hapd,
296780fb4a2SCy Schubert 				 struct sta_info *sta);
2975b9c547cSRui Paulo 	struct wpabuf *mesh_pending_auth;
2985b9c547cSRui Paulo 	struct os_reltime mesh_pending_auth_time;
299780fb4a2SCy Schubert 	u8 mesh_required_peer[ETH_ALEN];
3005b9c547cSRui Paulo #endif /* CONFIG_MESH */
301f05cddf9SRui Paulo 
302f05cddf9SRui Paulo #ifdef CONFIG_SQLITE
303f05cddf9SRui Paulo 	struct hostapd_eap_user tmp_eap_user;
304f05cddf9SRui Paulo #endif /* CONFIG_SQLITE */
3055b9c547cSRui Paulo 
3065b9c547cSRui Paulo #ifdef CONFIG_SAE
3075b9c547cSRui Paulo 	/** Key used for generating SAE anti-clogging tokens */
3085b9c547cSRui Paulo 	u8 sae_token_key[8];
3095b9c547cSRui Paulo 	struct os_reltime last_sae_token_key_update;
310325151a3SRui Paulo 	int dot11RSNASAERetransPeriod; /* msec */
3115b9c547cSRui Paulo #endif /* CONFIG_SAE */
3125b9c547cSRui Paulo 
3135b9c547cSRui Paulo #ifdef CONFIG_TESTING_OPTIONS
3145b9c547cSRui Paulo 	unsigned int ext_mgmt_frame_handling:1;
3155b9c547cSRui Paulo 	unsigned int ext_eapol_frame_io:1;
3165b9c547cSRui Paulo 
3175b9c547cSRui Paulo 	struct l2_packet_data *l2_test;
318*85732ac8SCy Schubert 
319*85732ac8SCy Schubert 	enum wpa_alg last_gtk_alg;
320*85732ac8SCy Schubert 	int last_gtk_key_idx;
321*85732ac8SCy Schubert 	u8 last_gtk[WPA_GTK_MAX_LEN];
322*85732ac8SCy Schubert 	size_t last_gtk_len;
323*85732ac8SCy Schubert 
324*85732ac8SCy Schubert #ifdef CONFIG_IEEE80211W
325*85732ac8SCy Schubert 	enum wpa_alg last_igtk_alg;
326*85732ac8SCy Schubert 	int last_igtk_key_idx;
327*85732ac8SCy Schubert 	u8 last_igtk[WPA_IGTK_MAX_LEN];
328*85732ac8SCy Schubert 	size_t last_igtk_len;
329*85732ac8SCy Schubert #endif /* CONFIG_IEEE80211W */
3305b9c547cSRui Paulo #endif /* CONFIG_TESTING_OPTIONS */
331780fb4a2SCy Schubert 
332780fb4a2SCy Schubert #ifdef CONFIG_MBO
333780fb4a2SCy Schubert 	unsigned int mbo_assoc_disallow;
334780fb4a2SCy Schubert #endif /* CONFIG_MBO */
335780fb4a2SCy Schubert 
336780fb4a2SCy Schubert 	struct dl_list nr_db;
337780fb4a2SCy Schubert 
338*85732ac8SCy Schubert 	u8 beacon_req_token;
339780fb4a2SCy Schubert 	u8 lci_req_token;
340780fb4a2SCy Schubert 	u8 range_req_token;
341780fb4a2SCy Schubert 	unsigned int lci_req_active:1;
342780fb4a2SCy Schubert 	unsigned int range_req_active:1;
343*85732ac8SCy Schubert 
344*85732ac8SCy Schubert 	int dhcp_sock; /* UDP socket used with the DHCP server */
345*85732ac8SCy Schubert 
346*85732ac8SCy Schubert #ifdef CONFIG_DPP
347*85732ac8SCy Schubert 	int dpp_init_done;
348*85732ac8SCy Schubert 	struct dpp_authentication *dpp_auth;
349*85732ac8SCy Schubert 	u8 dpp_allowed_roles;
350*85732ac8SCy Schubert 	int dpp_qr_mutual;
351*85732ac8SCy Schubert 	int dpp_auth_ok_on_ack;
352*85732ac8SCy Schubert 	int dpp_in_response_listen;
353*85732ac8SCy Schubert 	struct gas_query_ap *gas;
354*85732ac8SCy Schubert 	struct dpp_pkex *dpp_pkex;
355*85732ac8SCy Schubert 	struct dpp_bootstrap_info *dpp_pkex_bi;
356*85732ac8SCy Schubert 	char *dpp_pkex_code;
357*85732ac8SCy Schubert 	char *dpp_pkex_identifier;
358*85732ac8SCy Schubert 	char *dpp_pkex_auth_cmd;
359*85732ac8SCy Schubert 	char *dpp_configurator_params;
360*85732ac8SCy Schubert 	struct os_reltime dpp_last_init;
361*85732ac8SCy Schubert 	struct os_reltime dpp_init_iter_start;
362*85732ac8SCy Schubert 	unsigned int dpp_init_max_tries;
363*85732ac8SCy Schubert 	unsigned int dpp_init_retry_time;
364*85732ac8SCy Schubert 	unsigned int dpp_resp_wait_time;
365*85732ac8SCy Schubert 	unsigned int dpp_resp_max_tries;
366*85732ac8SCy Schubert 	unsigned int dpp_resp_retry_time;
367*85732ac8SCy Schubert #ifdef CONFIG_TESTING_OPTIONS
368*85732ac8SCy Schubert 	char *dpp_config_obj_override;
369*85732ac8SCy Schubert 	char *dpp_discovery_override;
370*85732ac8SCy Schubert 	char *dpp_groups_override;
371*85732ac8SCy Schubert 	unsigned int dpp_ignore_netaccesskey_mismatch:1;
372*85732ac8SCy Schubert #endif /* CONFIG_TESTING_OPTIONS */
373*85732ac8SCy Schubert #endif /* CONFIG_DPP */
374e28a4053SRui Paulo };
375e28a4053SRui Paulo 
376e28a4053SRui Paulo 
377325151a3SRui Paulo struct hostapd_sta_info {
378325151a3SRui Paulo 	struct dl_list list;
379325151a3SRui Paulo 	u8 addr[ETH_ALEN];
380325151a3SRui Paulo 	struct os_reltime last_seen;
381*85732ac8SCy Schubert 	int ssi_signal;
382780fb4a2SCy Schubert #ifdef CONFIG_TAXONOMY
383780fb4a2SCy Schubert 	struct wpabuf *probe_ie_taxonomy;
384780fb4a2SCy Schubert #endif /* CONFIG_TAXONOMY */
385325151a3SRui Paulo };
386325151a3SRui Paulo 
387e28a4053SRui Paulo /**
388e28a4053SRui Paulo  * struct hostapd_iface - hostapd per-interface data structure
389e28a4053SRui Paulo  */
390e28a4053SRui Paulo struct hostapd_iface {
391e28a4053SRui Paulo 	struct hapd_interfaces *interfaces;
392e28a4053SRui Paulo 	void *owner;
393e28a4053SRui Paulo 	char *config_fname;
394e28a4053SRui Paulo 	struct hostapd_config *conf;
3955b9c547cSRui Paulo 	char phy[16]; /* Name of the PHY (radio) */
3965b9c547cSRui Paulo 
3975b9c547cSRui Paulo 	enum hostapd_iface_state {
3985b9c547cSRui Paulo 		HAPD_IFACE_UNINITIALIZED,
3995b9c547cSRui Paulo 		HAPD_IFACE_DISABLED,
4005b9c547cSRui Paulo 		HAPD_IFACE_COUNTRY_UPDATE,
4015b9c547cSRui Paulo 		HAPD_IFACE_ACS,
4025b9c547cSRui Paulo 		HAPD_IFACE_HT_SCAN,
4035b9c547cSRui Paulo 		HAPD_IFACE_DFS,
4045b9c547cSRui Paulo 		HAPD_IFACE_ENABLED
4055b9c547cSRui Paulo 	} state;
4065b9c547cSRui Paulo 
4075b9c547cSRui Paulo #ifdef CONFIG_MESH
4085b9c547cSRui Paulo 	struct mesh_conf *mconf;
4095b9c547cSRui Paulo #endif /* CONFIG_MESH */
410e28a4053SRui Paulo 
411e28a4053SRui Paulo 	size_t num_bss;
412e28a4053SRui Paulo 	struct hostapd_data **bss;
413e28a4053SRui Paulo 
4145b9c547cSRui Paulo 	unsigned int wait_channel_update:1;
4155b9c547cSRui Paulo 	unsigned int cac_started:1;
416325151a3SRui Paulo #ifdef CONFIG_FST
417325151a3SRui Paulo 	struct fst_iface *fst;
418325151a3SRui Paulo 	const struct wpabuf *fst_ies;
419325151a3SRui Paulo #endif /* CONFIG_FST */
4205b9c547cSRui Paulo 
4215b9c547cSRui Paulo 	/*
4225b9c547cSRui Paulo 	 * When set, indicates that the driver will handle the AP
4235b9c547cSRui Paulo 	 * teardown: delete global keys, station keys, and stations.
4245b9c547cSRui Paulo 	 */
4255b9c547cSRui Paulo 	unsigned int driver_ap_teardown:1;
4265b9c547cSRui Paulo 
427780fb4a2SCy Schubert 	/*
428780fb4a2SCy Schubert 	 * When set, indicates that this interface is part of list of
429780fb4a2SCy Schubert 	 * interfaces that need to be started together (synchronously).
430780fb4a2SCy Schubert 	 */
431780fb4a2SCy Schubert 	unsigned int need_to_start_in_sync:1;
432780fb4a2SCy Schubert 
433780fb4a2SCy Schubert 	/* Ready to start but waiting for other interfaces to become ready. */
434780fb4a2SCy Schubert 	unsigned int ready_to_start_in_sync:1;
435780fb4a2SCy Schubert 
436e28a4053SRui Paulo 	int num_ap; /* number of entries in ap_list */
437e28a4053SRui Paulo 	struct ap_info *ap_list; /* AP info list head */
438e28a4053SRui Paulo 	struct ap_info *ap_hash[STA_HASH_SIZE];
439e28a4053SRui Paulo 
4405b9c547cSRui Paulo 	u64 drv_flags;
4415b9c547cSRui Paulo 
4425b9c547cSRui Paulo 	/* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */
4435b9c547cSRui Paulo 	unsigned int smps_modes;
444f05cddf9SRui Paulo 
445f05cddf9SRui Paulo 	/*
446f05cddf9SRui Paulo 	 * A bitmap of supported protocols for probe response offload. See
447f05cddf9SRui Paulo 	 * struct wpa_driver_capa in driver.h
448f05cddf9SRui Paulo 	 */
449f05cddf9SRui Paulo 	unsigned int probe_resp_offloads;
450f05cddf9SRui Paulo 
4515b9c547cSRui Paulo 	/* extended capabilities supported by the driver */
4525b9c547cSRui Paulo 	const u8 *extended_capa, *extended_capa_mask;
4535b9c547cSRui Paulo 	unsigned int extended_capa_len;
4545b9c547cSRui Paulo 
4555b9c547cSRui Paulo 	unsigned int drv_max_acl_mac_addrs;
4565b9c547cSRui Paulo 
457e28a4053SRui Paulo 	struct hostapd_hw_modes *hw_features;
458e28a4053SRui Paulo 	int num_hw_features;
459e28a4053SRui Paulo 	struct hostapd_hw_modes *current_mode;
460e28a4053SRui Paulo 	/* Rates that are currently used (i.e., filtered copy of
461e28a4053SRui Paulo 	 * current_mode->channels */
462e28a4053SRui Paulo 	int num_rates;
463e28a4053SRui Paulo 	struct hostapd_rate_data *current_rates;
464f05cddf9SRui Paulo 	int *basic_rates;
465e28a4053SRui Paulo 	int freq;
466e28a4053SRui Paulo 
467e28a4053SRui Paulo 	u16 hw_flags;
468e28a4053SRui Paulo 
469e28a4053SRui Paulo 	/* Number of associated Non-ERP stations (i.e., stations using 802.11b
470e28a4053SRui Paulo 	 * in 802.11g BSS) */
471e28a4053SRui Paulo 	int num_sta_non_erp;
472e28a4053SRui Paulo 
473e28a4053SRui Paulo 	/* Number of associated stations that do not support Short Slot Time */
474e28a4053SRui Paulo 	int num_sta_no_short_slot_time;
475e28a4053SRui Paulo 
476e28a4053SRui Paulo 	/* Number of associated stations that do not support Short Preamble */
477e28a4053SRui Paulo 	int num_sta_no_short_preamble;
478e28a4053SRui Paulo 
479e28a4053SRui Paulo 	int olbc; /* Overlapping Legacy BSS Condition */
480e28a4053SRui Paulo 
481e28a4053SRui Paulo 	/* Number of HT associated stations that do not support greenfield */
482e28a4053SRui Paulo 	int num_sta_ht_no_gf;
483e28a4053SRui Paulo 
484e28a4053SRui Paulo 	/* Number of associated non-HT stations */
485e28a4053SRui Paulo 	int num_sta_no_ht;
486e28a4053SRui Paulo 
487e28a4053SRui Paulo 	/* Number of HT associated stations 20 MHz */
488e28a4053SRui Paulo 	int num_sta_ht_20mhz;
489e28a4053SRui Paulo 
4905b9c547cSRui Paulo 	/* Number of HT40 intolerant stations */
4915b9c547cSRui Paulo 	int num_sta_ht40_intolerant;
4925b9c547cSRui Paulo 
493e28a4053SRui Paulo 	/* Overlapping BSS information */
494e28a4053SRui Paulo 	int olbc_ht;
495e28a4053SRui Paulo 
496e28a4053SRui Paulo 	u16 ht_op_mode;
4975b9c547cSRui Paulo 
4985b9c547cSRui Paulo 	/* surveying helpers */
4995b9c547cSRui Paulo 
5005b9c547cSRui Paulo 	/* number of channels surveyed */
5015b9c547cSRui Paulo 	unsigned int chans_surveyed;
5025b9c547cSRui Paulo 
5035b9c547cSRui Paulo 	/* lowest observed noise floor in dBm */
5045b9c547cSRui Paulo 	s8 lowest_nf;
5055b9c547cSRui Paulo 
5065b9c547cSRui Paulo 	/* channel utilization calculation */
5075b9c547cSRui Paulo 	u64 last_channel_time;
5085b9c547cSRui Paulo 	u64 last_channel_time_busy;
5095b9c547cSRui Paulo 	u8 channel_utilization;
5105b9c547cSRui Paulo 
511*85732ac8SCy Schubert 	unsigned int chan_util_samples_sum;
512*85732ac8SCy Schubert 	unsigned int chan_util_num_sample_periods;
513*85732ac8SCy Schubert 	unsigned int chan_util_average;
514*85732ac8SCy Schubert 
515780fb4a2SCy Schubert 	/* eCSA IE will be added only if operating class is specified */
516780fb4a2SCy Schubert 	u8 cs_oper_class;
517780fb4a2SCy Schubert 
5185b9c547cSRui Paulo 	unsigned int dfs_cac_ms;
5195b9c547cSRui Paulo 	struct os_reltime dfs_cac_start;
5205b9c547cSRui Paulo 
5215b9c547cSRui Paulo 	/* Latched with the actual secondary channel information and will be
5225b9c547cSRui Paulo 	 * used while juggling between HT20 and HT40 modes. */
5235b9c547cSRui Paulo 	int secondary_ch;
5245b9c547cSRui Paulo 
5255b9c547cSRui Paulo #ifdef CONFIG_ACS
5265b9c547cSRui Paulo 	unsigned int acs_num_completed_scans;
5275b9c547cSRui Paulo #endif /* CONFIG_ACS */
5285b9c547cSRui Paulo 
529e28a4053SRui Paulo 	void (*scan_cb)(struct hostapd_iface *iface);
5305b9c547cSRui Paulo 	int num_ht40_scan_tries;
531325151a3SRui Paulo 
532325151a3SRui Paulo 	struct dl_list sta_seen; /* struct hostapd_sta_info */
533325151a3SRui Paulo 	unsigned int num_sta_seen;
534*85732ac8SCy Schubert 
535*85732ac8SCy Schubert 	u8 dfs_domain;
536e28a4053SRui Paulo };
537e28a4053SRui Paulo 
538e28a4053SRui Paulo /* hostapd.c */
539f05cddf9SRui Paulo int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
540f05cddf9SRui Paulo 			       int (*cb)(struct hostapd_iface *iface,
541f05cddf9SRui Paulo 					 void *ctx), void *ctx);
542e28a4053SRui Paulo int hostapd_reload_config(struct hostapd_iface *iface);
543*85732ac8SCy Schubert void hostapd_reconfig_encryption(struct hostapd_data *hapd);
544e28a4053SRui Paulo struct hostapd_data *
545e28a4053SRui Paulo hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
546e28a4053SRui Paulo 		       struct hostapd_config *conf,
547e28a4053SRui Paulo 		       struct hostapd_bss_config *bss);
548e28a4053SRui Paulo int hostapd_setup_interface(struct hostapd_iface *iface);
549e28a4053SRui Paulo int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
550e28a4053SRui Paulo void hostapd_interface_deinit(struct hostapd_iface *iface);
551e28a4053SRui Paulo void hostapd_interface_free(struct hostapd_iface *iface);
552780fb4a2SCy Schubert struct hostapd_iface * hostapd_alloc_iface(void);
5535b9c547cSRui Paulo struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
5545b9c547cSRui Paulo 				    const char *config_file);
5555b9c547cSRui Paulo struct hostapd_iface *
5565b9c547cSRui Paulo hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
5575b9c547cSRui Paulo 			   const char *config_fname, int debug);
558e28a4053SRui Paulo void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
559e28a4053SRui Paulo 			   int reassoc);
560f05cddf9SRui Paulo void hostapd_interface_deinit_free(struct hostapd_iface *iface);
561f05cddf9SRui Paulo int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
562f05cddf9SRui Paulo int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
563f05cddf9SRui Paulo int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
564f05cddf9SRui Paulo int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
565f05cddf9SRui Paulo int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
5665b9c547cSRui Paulo void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
5675b9c547cSRui Paulo void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
5685b9c547cSRui Paulo const char * hostapd_state_text(enum hostapd_iface_state s);
569780fb4a2SCy Schubert int hostapd_csa_in_progress(struct hostapd_iface *iface);
570*85732ac8SCy Schubert void hostapd_chan_switch_vht_config(struct hostapd_data *hapd, int vht_enabled);
5715b9c547cSRui Paulo int hostapd_switch_channel(struct hostapd_data *hapd,
5725b9c547cSRui Paulo 			   struct csa_settings *settings);
5735b9c547cSRui Paulo void
5745b9c547cSRui Paulo hostapd_switch_channel_fallback(struct hostapd_iface *iface,
5755b9c547cSRui Paulo 				const struct hostapd_freq_params *freq_params);
5765b9c547cSRui Paulo void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
577325151a3SRui Paulo void hostapd_periodic_iface(struct hostapd_iface *iface);
578*85732ac8SCy Schubert int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
579e28a4053SRui Paulo 
580e28a4053SRui Paulo /* utils.c */
581e28a4053SRui Paulo int hostapd_register_probereq_cb(struct hostapd_data *hapd,
582e28a4053SRui Paulo 				 int (*cb)(void *ctx, const u8 *sa,
583f05cddf9SRui Paulo 					   const u8 *da, const u8 *bssid,
584f05cddf9SRui Paulo 					   const u8 *ie, size_t ie_len,
585f05cddf9SRui Paulo 					   int ssi_signal),
586e28a4053SRui Paulo 				 void *ctx);
587e28a4053SRui Paulo void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
588e28a4053SRui Paulo 
589e28a4053SRui Paulo /* drv_callbacks.c (TODO: move to somewhere else?) */
590*85732ac8SCy Schubert void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd,
591*85732ac8SCy Schubert 				      struct sta_info *sta);
592e28a4053SRui Paulo int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
593f05cddf9SRui Paulo 			const u8 *ie, size_t ielen, int reassoc);
594e28a4053SRui Paulo void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
595f05cddf9SRui Paulo void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
5965b9c547cSRui Paulo void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
5975b9c547cSRui Paulo 					 const u8 *addr, int reason_code);
598f05cddf9SRui Paulo int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
599f05cddf9SRui Paulo 			 const u8 *bssid, const u8 *ie, size_t ie_len,
600f05cddf9SRui Paulo 			 int ssi_signal);
601f05cddf9SRui Paulo void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
6025b9c547cSRui Paulo 			     int offset, int width, int cf1, int cf2);
603780fb4a2SCy Schubert struct survey_results;
604780fb4a2SCy Schubert void hostapd_event_get_survey(struct hostapd_iface *iface,
605780fb4a2SCy Schubert 			      struct survey_results *survey_results);
606780fb4a2SCy Schubert void hostapd_acs_channel_selected(struct hostapd_data *hapd,
607780fb4a2SCy Schubert 				  struct acs_selected_channels *acs_res);
608f05cddf9SRui Paulo 
609f05cddf9SRui Paulo const struct hostapd_eap_user *
610f05cddf9SRui Paulo hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
611f05cddf9SRui Paulo 		     size_t identity_len, int phase2);
612e28a4053SRui Paulo 
613325151a3SRui Paulo struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces,
614325151a3SRui Paulo 					const char *ifname);
615*85732ac8SCy Schubert void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr,
616*85732ac8SCy Schubert 				      enum smps_mode smps_mode,
617*85732ac8SCy Schubert 				      enum chan_width chan_width, u8 rx_nss);
618325151a3SRui Paulo 
619325151a3SRui Paulo #ifdef CONFIG_FST
620325151a3SRui Paulo void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
621325151a3SRui Paulo 				struct fst_wpa_obj *iface_obj);
622325151a3SRui Paulo #endif /* CONFIG_FST */
623325151a3SRui Paulo 
624e28a4053SRui Paulo #endif /* HOSTAPD_H */
625