xref: /freebsd/contrib/wpa/src/ap/hostapd.h (revision 4b72b91a)
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 
12206b73d0SCy Schubert #ifdef CONFIG_SQLITE
13206b73d0SCy Schubert #include <sqlite3.h>
14206b73d0SCy Schubert #endif /* CONFIG_SQLITE */
15206b73d0SCy Schubert 
16e28a4053SRui Paulo #include "common/defs.h"
175b9c547cSRui Paulo #include "utils/list.h"
18f05cddf9SRui Paulo #include "ap_config.h"
195b9c547cSRui Paulo #include "drivers/driver.h"
20e28a4053SRui Paulo 
2185732ac8SCy Schubert #define OCE_STA_CFON_ENABLED(hapd) \
2285732ac8SCy Schubert 	((hapd->conf->oce & OCE_STA_CFON) && \
2385732ac8SCy Schubert 	 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_STA_CFON))
2485732ac8SCy Schubert #define OCE_AP_ENABLED(hapd) \
2585732ac8SCy Schubert 	((hapd->conf->oce & OCE_AP) && \
2685732ac8SCy Schubert 	 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_AP))
2785732ac8SCy Schubert 
28e28a4053SRui Paulo struct wpa_ctrl_dst;
29e28a4053SRui Paulo struct radius_server_data;
30e28a4053SRui Paulo struct upnp_wps_device_sm;
31e28a4053SRui Paulo struct hostapd_data;
32e28a4053SRui Paulo struct sta_info;
33e28a4053SRui Paulo struct ieee80211_ht_capabilities;
34e28a4053SRui Paulo struct full_dynamic_vlan;
35f05cddf9SRui Paulo enum wps_event;
36f05cddf9SRui Paulo union wps_event_data;
375b9c547cSRui Paulo #ifdef CONFIG_MESH
385b9c547cSRui Paulo struct mesh_conf;
395b9c547cSRui Paulo #endif /* CONFIG_MESH */
40f05cddf9SRui Paulo 
41c1d255d3SCy Schubert #ifdef CONFIG_CTRL_IFACE_UDP
42c1d255d3SCy Schubert #define CTRL_IFACE_COOKIE_LEN 8
43c1d255d3SCy Schubert #endif /* CONFIG_CTRL_IFACE_UDP */
44c1d255d3SCy Schubert 
45f05cddf9SRui Paulo struct hostapd_iface;
46f05cddf9SRui Paulo 
47f05cddf9SRui Paulo struct hapd_interfaces {
48f05cddf9SRui Paulo 	int (*reload_config)(struct hostapd_iface *iface);
49f05cddf9SRui Paulo 	struct hostapd_config * (*config_read_cb)(const char *config_fname);
50f05cddf9SRui Paulo 	int (*ctrl_iface_init)(struct hostapd_data *hapd);
51f05cddf9SRui Paulo 	void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
52f05cddf9SRui Paulo 	int (*for_each_interface)(struct hapd_interfaces *interfaces,
53f05cddf9SRui Paulo 				  int (*cb)(struct hostapd_iface *iface,
54f05cddf9SRui Paulo 					    void *ctx), void *ctx);
55f05cddf9SRui Paulo 	int (*driver_init)(struct hostapd_iface *iface);
56f05cddf9SRui Paulo 
57f05cddf9SRui Paulo 	size_t count;
58f05cddf9SRui Paulo 	int global_ctrl_sock;
59780fb4a2SCy Schubert 	struct dl_list global_ctrl_dst;
60f05cddf9SRui Paulo 	char *global_iface_path;
61f05cddf9SRui Paulo 	char *global_iface_name;
625b9c547cSRui Paulo #ifndef CONFIG_NATIVE_WINDOWS
635b9c547cSRui Paulo 	gid_t ctrl_iface_group;
645b9c547cSRui Paulo #endif /* CONFIG_NATIVE_WINDOWS */
65f05cddf9SRui Paulo 	struct hostapd_iface **iface;
665b9c547cSRui Paulo 
675b9c547cSRui Paulo 	size_t terminate_on_error;
68325151a3SRui Paulo #ifndef CONFIG_NO_VLAN
69325151a3SRui Paulo 	struct dynamic_iface *vlan_priv;
70325151a3SRui Paulo #endif /* CONFIG_NO_VLAN */
7185732ac8SCy Schubert #ifdef CONFIG_ETH_P_OUI
7285732ac8SCy Schubert 	struct dl_list eth_p_oui; /* OUI Extended EtherType handlers */
7385732ac8SCy Schubert #endif /* CONFIG_ETH_P_OUI */
74780fb4a2SCy Schubert 	int eloop_initialized;
7585732ac8SCy Schubert 
7685732ac8SCy Schubert #ifdef CONFIG_DPP
774bc52338SCy Schubert 	struct dpp_global *dpp;
7885732ac8SCy Schubert #endif /* CONFIG_DPP */
79c1d255d3SCy Schubert 
80c1d255d3SCy Schubert #ifdef CONFIG_CTRL_IFACE_UDP
81c1d255d3SCy Schubert        unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
82c1d255d3SCy Schubert #endif /* CONFIG_CTRL_IFACE_UDP */
83c1d255d3SCy Schubert 
84f05cddf9SRui Paulo };
85f05cddf9SRui Paulo 
865b9c547cSRui Paulo enum hostapd_chan_status {
875b9c547cSRui Paulo 	HOSTAPD_CHAN_VALID = 0, /* channel is ready */
885b9c547cSRui Paulo 	HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */
895b9c547cSRui Paulo 	HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */
905b9c547cSRui Paulo };
91e28a4053SRui Paulo 
92e28a4053SRui Paulo struct hostapd_probereq_cb {
93f05cddf9SRui Paulo 	int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
94f05cddf9SRui Paulo 		  const u8 *ie, size_t ie_len, int ssi_signal);
95e28a4053SRui Paulo 	void *ctx;
96e28a4053SRui Paulo };
97e28a4053SRui Paulo 
98e28a4053SRui Paulo #define HOSTAPD_RATE_BASIC 0x00000001
99e28a4053SRui Paulo 
100e28a4053SRui Paulo struct hostapd_rate_data {
101e28a4053SRui Paulo 	int rate; /* rate in 100 kbps */
102e28a4053SRui Paulo 	int flags; /* HOSTAPD_RATE_ flags */
103e28a4053SRui Paulo };
104e28a4053SRui Paulo 
105e28a4053SRui Paulo struct hostapd_frame_info {
10685732ac8SCy Schubert 	unsigned int freq;
107e28a4053SRui Paulo 	u32 channel;
108e28a4053SRui Paulo 	u32 datarate;
109f05cddf9SRui Paulo 	int ssi_signal; /* dBm */
110e28a4053SRui Paulo };
111e28a4053SRui Paulo 
1125b9c547cSRui Paulo enum wps_status {
1135b9c547cSRui Paulo 	WPS_STATUS_SUCCESS = 1,
1145b9c547cSRui Paulo 	WPS_STATUS_FAILURE
1155b9c547cSRui Paulo };
1165b9c547cSRui Paulo 
1175b9c547cSRui Paulo enum pbc_status {
1185b9c547cSRui Paulo 	WPS_PBC_STATUS_DISABLE,
1195b9c547cSRui Paulo 	WPS_PBC_STATUS_ACTIVE,
1205b9c547cSRui Paulo 	WPS_PBC_STATUS_TIMEOUT,
1215b9c547cSRui Paulo 	WPS_PBC_STATUS_OVERLAP
1225b9c547cSRui Paulo };
1235b9c547cSRui Paulo 
1245b9c547cSRui Paulo struct wps_stat {
1255b9c547cSRui Paulo 	enum wps_status status;
1265b9c547cSRui Paulo 	enum wps_error_indication failure_reason;
1275b9c547cSRui Paulo 	enum pbc_status pbc_status;
1285b9c547cSRui Paulo 	u8 peer_addr[ETH_ALEN];
1295b9c547cSRui Paulo };
1305b9c547cSRui Paulo 
131780fb4a2SCy Schubert struct hostapd_neighbor_entry {
132780fb4a2SCy Schubert 	struct dl_list list;
133780fb4a2SCy Schubert 	u8 bssid[ETH_ALEN];
134780fb4a2SCy Schubert 	struct wpa_ssid_value ssid;
135780fb4a2SCy Schubert 	struct wpabuf *nr;
136780fb4a2SCy Schubert 	struct wpabuf *lci;
137780fb4a2SCy Schubert 	struct wpabuf *civic;
138780fb4a2SCy Schubert 	/* LCI update time */
139780fb4a2SCy Schubert 	struct os_time lci_date;
14085732ac8SCy Schubert 	int stationary;
1414b72b91aSCy Schubert 	u32 short_ssid;
1424b72b91aSCy Schubert 	u8 bss_parameters;
143780fb4a2SCy Schubert };
144e28a4053SRui Paulo 
1454bc52338SCy Schubert struct hostapd_sae_commit_queue {
1464bc52338SCy Schubert 	struct dl_list list;
1474bc52338SCy Schubert 	int rssi;
1484bc52338SCy Schubert 	size_t len;
1494bc52338SCy Schubert 	u8 msg[];
1504bc52338SCy Schubert };
1514bc52338SCy Schubert 
152e28a4053SRui Paulo /**
153e28a4053SRui Paulo  * struct hostapd_data - hostapd per-BSS data structure
154e28a4053SRui Paulo  */
155e28a4053SRui Paulo struct hostapd_data {
156e28a4053SRui Paulo 	struct hostapd_iface *iface;
157e28a4053SRui Paulo 	struct hostapd_config *iconf;
158e28a4053SRui Paulo 	struct hostapd_bss_config *conf;
159e28a4053SRui Paulo 	int interface_added; /* virtual interface added for this BSS */
1605b9c547cSRui Paulo 	unsigned int started:1;
1615b9c547cSRui Paulo 	unsigned int disabled:1;
1625b9c547cSRui Paulo 	unsigned int reenable_beacon:1;
163e28a4053SRui Paulo 
164e28a4053SRui Paulo 	u8 own_addr[ETH_ALEN];
165e28a4053SRui Paulo 
166e28a4053SRui Paulo 	int num_sta; /* number of entries in sta_list */
167e28a4053SRui Paulo 	struct sta_info *sta_list; /* STA info list head */
168e28a4053SRui Paulo #define STA_HASH_SIZE 256
169e28a4053SRui Paulo #define STA_HASH(sta) (sta[5])
170e28a4053SRui Paulo 	struct sta_info *sta_hash[STA_HASH_SIZE];
171e28a4053SRui Paulo 
172e28a4053SRui Paulo 	/*
173e28a4053SRui Paulo 	 * Bitfield for indicating which AIDs are allocated. Only AID values
174e28a4053SRui Paulo 	 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
175e28a4053SRui Paulo 	 * 1.
176e28a4053SRui Paulo 	 */
177e28a4053SRui Paulo #define AID_WORDS ((2008 + 31) / 32)
178e28a4053SRui Paulo 	u32 sta_aid[AID_WORDS];
179e28a4053SRui Paulo 
180e28a4053SRui Paulo 	const struct wpa_driver_ops *driver;
181e28a4053SRui Paulo 	void *drv_priv;
182e28a4053SRui Paulo 
183e28a4053SRui Paulo 	void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
184e28a4053SRui Paulo 				 struct sta_info *sta, int reassoc);
185e28a4053SRui Paulo 
186e28a4053SRui Paulo 	void *msg_ctx; /* ctx for wpa_msg() calls */
187f05cddf9SRui Paulo 	void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
188e28a4053SRui Paulo 
189e28a4053SRui Paulo 	struct radius_client_data *radius;
190780fb4a2SCy Schubert 	u64 acct_session_id;
191f05cddf9SRui Paulo 	struct radius_das_data *radius_das;
192e28a4053SRui Paulo 
193e28a4053SRui Paulo 	struct hostapd_cached_radius_acl *acl_cache;
194e28a4053SRui Paulo 	struct hostapd_acl_query_data *acl_queries;
195e28a4053SRui Paulo 
196e28a4053SRui Paulo 	struct wpa_authenticator *wpa_auth;
197e28a4053SRui Paulo 	struct eapol_authenticator *eapol_auth;
198c1d255d3SCy Schubert 	struct eap_config *eap_cfg;
199e28a4053SRui Paulo 
200e28a4053SRui Paulo 	struct rsn_preauth_interface *preauth_iface;
2015b9c547cSRui Paulo 	struct os_reltime michael_mic_failure;
202e28a4053SRui Paulo 	int michael_mic_failures;
203e28a4053SRui Paulo 	int tkip_countermeasures;
204e28a4053SRui Paulo 
205e28a4053SRui Paulo 	int ctrl_sock;
206780fb4a2SCy Schubert 	struct dl_list ctrl_dst;
207e28a4053SRui Paulo 
208e28a4053SRui Paulo 	void *ssl_ctx;
209e28a4053SRui Paulo 	void *eap_sim_db_priv;
210e28a4053SRui Paulo 	struct radius_server_data *radius_srv;
2115b9c547cSRui Paulo 	struct dl_list erp_keys; /* struct eap_server_erp_key */
212e28a4053SRui Paulo 
213e28a4053SRui Paulo 	int parameter_set_count;
214e28a4053SRui Paulo 
215f05cddf9SRui Paulo 	/* Time Advertisement */
216f05cddf9SRui Paulo 	u8 time_update_counter;
217f05cddf9SRui Paulo 	struct wpabuf *time_adv;
218f05cddf9SRui Paulo 
219e28a4053SRui Paulo #ifdef CONFIG_FULL_DYNAMIC_VLAN
220e28a4053SRui Paulo 	struct full_dynamic_vlan *full_dynamic_vlan;
221e28a4053SRui Paulo #endif /* CONFIG_FULL_DYNAMIC_VLAN */
222e28a4053SRui Paulo 
223e28a4053SRui Paulo 	struct l2_packet_data *l2;
22485732ac8SCy Schubert 
22585732ac8SCy Schubert #ifdef CONFIG_IEEE80211R_AP
22685732ac8SCy Schubert 	struct dl_list l2_queue;
22785732ac8SCy Schubert 	struct dl_list l2_oui_queue;
22885732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_pull;
22985732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_resp;
23085732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_push;
23185732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_sreq;
23285732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_sresp;
23385732ac8SCy Schubert #endif /* CONFIG_IEEE80211R_AP */
23485732ac8SCy Schubert 
235e28a4053SRui Paulo 	struct wps_context *wps;
236e28a4053SRui Paulo 
237f05cddf9SRui Paulo 	int beacon_set_done;
238e28a4053SRui Paulo 	struct wpabuf *wps_beacon_ie;
239e28a4053SRui Paulo 	struct wpabuf *wps_probe_resp_ie;
240e28a4053SRui Paulo #ifdef CONFIG_WPS
241e28a4053SRui Paulo 	unsigned int ap_pin_failures;
242f05cddf9SRui Paulo 	unsigned int ap_pin_failures_consecutive;
243e28a4053SRui Paulo 	struct upnp_wps_device_sm *wps_upnp;
244e28a4053SRui Paulo 	unsigned int ap_pin_lockout_time;
2455b9c547cSRui Paulo 
2465b9c547cSRui Paulo 	struct wps_stat wps_stats;
247e28a4053SRui Paulo #endif /* CONFIG_WPS */
248e28a4053SRui Paulo 
249206b73d0SCy Schubert #ifdef CONFIG_MACSEC
250206b73d0SCy Schubert 	struct ieee802_1x_kay *kay;
251206b73d0SCy Schubert #endif /* CONFIG_MACSEC */
252206b73d0SCy Schubert 
253e28a4053SRui Paulo 	struct hostapd_probereq_cb *probereq_cb;
254e28a4053SRui Paulo 	size_t num_probereq_cb;
255e28a4053SRui Paulo 
256e28a4053SRui Paulo 	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
257e28a4053SRui Paulo 				 int freq);
258e28a4053SRui Paulo 	void *public_action_cb_ctx;
2595b9c547cSRui Paulo 	void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
2605b9c547cSRui Paulo 				  int freq);
2615b9c547cSRui Paulo 	void *public_action_cb2_ctx;
262e28a4053SRui Paulo 
263f05cddf9SRui Paulo 	int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
264f05cddf9SRui Paulo 				int freq);
265f05cddf9SRui Paulo 	void *vendor_action_cb_ctx;
266f05cddf9SRui Paulo 
267e28a4053SRui Paulo 	void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
268e28a4053SRui Paulo 				   const u8 *uuid_e);
269e28a4053SRui Paulo 	void *wps_reg_success_cb_ctx;
270f05cddf9SRui Paulo 
271f05cddf9SRui Paulo 	void (*wps_event_cb)(void *ctx, enum wps_event event,
272f05cddf9SRui Paulo 			     union wps_event_data *data);
273f05cddf9SRui Paulo 	void *wps_event_cb_ctx;
274f05cddf9SRui Paulo 
275f05cddf9SRui Paulo 	void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
276f05cddf9SRui Paulo 				  int authorized, const u8 *p2p_dev_addr);
277f05cddf9SRui Paulo 	void *sta_authorized_cb_ctx;
278f05cddf9SRui Paulo 
279f05cddf9SRui Paulo 	void (*setup_complete_cb)(void *ctx);
280f05cddf9SRui Paulo 	void *setup_complete_cb_ctx;
281f05cddf9SRui Paulo 
2825b9c547cSRui Paulo 	void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
2835b9c547cSRui Paulo 			   const u8 *p2p_dev_addr, const u8 *psk,
2845b9c547cSRui Paulo 			   size_t psk_len);
2855b9c547cSRui Paulo 	void *new_psk_cb_ctx;
2865b9c547cSRui Paulo 
2875b9c547cSRui Paulo 	/* channel switch parameters */
2885b9c547cSRui Paulo 	struct hostapd_freq_params cs_freq_params;
2895b9c547cSRui Paulo 	u8 cs_count;
2905b9c547cSRui Paulo 	int cs_block_tx;
2915b9c547cSRui Paulo 	unsigned int cs_c_off_beacon;
2925b9c547cSRui Paulo 	unsigned int cs_c_off_proberesp;
2935b9c547cSRui Paulo 	int csa_in_progress;
294780fb4a2SCy Schubert 	unsigned int cs_c_off_ecsa_beacon;
295780fb4a2SCy Schubert 	unsigned int cs_c_off_ecsa_proberesp;
2965b9c547cSRui Paulo 
297f05cddf9SRui Paulo #ifdef CONFIG_P2P
298f05cddf9SRui Paulo 	struct p2p_data *p2p;
299f05cddf9SRui Paulo 	struct p2p_group *p2p_group;
300f05cddf9SRui Paulo 	struct wpabuf *p2p_beacon_ie;
301f05cddf9SRui Paulo 	struct wpabuf *p2p_probe_resp_ie;
302f05cddf9SRui Paulo 
303f05cddf9SRui Paulo 	/* Number of non-P2P association stations */
304f05cddf9SRui Paulo 	int num_sta_no_p2p;
305f05cddf9SRui Paulo 
306f05cddf9SRui Paulo 	/* Periodic NoA (used only when no non-P2P clients in the group) */
307f05cddf9SRui Paulo 	int noa_enabled;
308f05cddf9SRui Paulo 	int noa_start;
309f05cddf9SRui Paulo 	int noa_duration;
310f05cddf9SRui Paulo #endif /* CONFIG_P2P */
3115b9c547cSRui Paulo #ifdef CONFIG_PROXYARP
3125b9c547cSRui Paulo 	struct l2_packet_data *sock_dhcp;
3135b9c547cSRui Paulo 	struct l2_packet_data *sock_ndisc;
3145b9c547cSRui Paulo #endif /* CONFIG_PROXYARP */
3155b9c547cSRui Paulo #ifdef CONFIG_MESH
3165b9c547cSRui Paulo 	int num_plinks;
3175b9c547cSRui Paulo 	int max_plinks;
318780fb4a2SCy Schubert 	void (*mesh_sta_free_cb)(struct hostapd_data *hapd,
319780fb4a2SCy Schubert 				 struct sta_info *sta);
3205b9c547cSRui Paulo 	struct wpabuf *mesh_pending_auth;
3215b9c547cSRui Paulo 	struct os_reltime mesh_pending_auth_time;
322780fb4a2SCy Schubert 	u8 mesh_required_peer[ETH_ALEN];
3235b9c547cSRui Paulo #endif /* CONFIG_MESH */
324f05cddf9SRui Paulo 
325f05cddf9SRui Paulo #ifdef CONFIG_SQLITE
326f05cddf9SRui Paulo 	struct hostapd_eap_user tmp_eap_user;
327f05cddf9SRui Paulo #endif /* CONFIG_SQLITE */
3285b9c547cSRui Paulo 
3295b9c547cSRui Paulo #ifdef CONFIG_SAE
3305b9c547cSRui Paulo 	/** Key used for generating SAE anti-clogging tokens */
331c1d255d3SCy Schubert 	u8 comeback_key[8];
332c1d255d3SCy Schubert 	struct os_reltime last_comeback_key_update;
333c1d255d3SCy Schubert 	u16 comeback_idx;
334c1d255d3SCy Schubert 	u16 comeback_pending_idx[256];
335325151a3SRui Paulo 	int dot11RSNASAERetransPeriod; /* msec */
3364bc52338SCy Schubert 	struct dl_list sae_commit_queue; /* struct hostapd_sae_commit_queue */
3375b9c547cSRui Paulo #endif /* CONFIG_SAE */
3385b9c547cSRui Paulo 
3395b9c547cSRui Paulo #ifdef CONFIG_TESTING_OPTIONS
3405b9c547cSRui Paulo 	unsigned int ext_mgmt_frame_handling:1;
3415b9c547cSRui Paulo 	unsigned int ext_eapol_frame_io:1;
3425b9c547cSRui Paulo 
3435b9c547cSRui Paulo 	struct l2_packet_data *l2_test;
34485732ac8SCy Schubert 
34585732ac8SCy Schubert 	enum wpa_alg last_gtk_alg;
34685732ac8SCy Schubert 	int last_gtk_key_idx;
34785732ac8SCy Schubert 	u8 last_gtk[WPA_GTK_MAX_LEN];
34885732ac8SCy Schubert 	size_t last_gtk_len;
34985732ac8SCy Schubert 
35085732ac8SCy Schubert 	enum wpa_alg last_igtk_alg;
35185732ac8SCy Schubert 	int last_igtk_key_idx;
35285732ac8SCy Schubert 	u8 last_igtk[WPA_IGTK_MAX_LEN];
35385732ac8SCy Schubert 	size_t last_igtk_len;
354c1d255d3SCy Schubert 
355c1d255d3SCy Schubert 	enum wpa_alg last_bigtk_alg;
356c1d255d3SCy Schubert 	int last_bigtk_key_idx;
357c1d255d3SCy Schubert 	u8 last_bigtk[WPA_BIGTK_MAX_LEN];
358c1d255d3SCy Schubert 	size_t last_bigtk_len;
359c1d255d3SCy Schubert 
360c1d255d3SCy Schubert 	bool force_backlog_bytes;
3615b9c547cSRui Paulo #endif /* CONFIG_TESTING_OPTIONS */
362780fb4a2SCy Schubert 
363780fb4a2SCy Schubert #ifdef CONFIG_MBO
364780fb4a2SCy Schubert 	unsigned int mbo_assoc_disallow;
365780fb4a2SCy Schubert #endif /* CONFIG_MBO */
366780fb4a2SCy Schubert 
367780fb4a2SCy Schubert 	struct dl_list nr_db;
368780fb4a2SCy Schubert 
36985732ac8SCy Schubert 	u8 beacon_req_token;
370780fb4a2SCy Schubert 	u8 lci_req_token;
371780fb4a2SCy Schubert 	u8 range_req_token;
372780fb4a2SCy Schubert 	unsigned int lci_req_active:1;
373780fb4a2SCy Schubert 	unsigned int range_req_active:1;
37485732ac8SCy Schubert 
37585732ac8SCy Schubert 	int dhcp_sock; /* UDP socket used with the DHCP server */
37685732ac8SCy Schubert 
377c1d255d3SCy Schubert 	struct ptksa_cache *ptksa;
378c1d255d3SCy Schubert 
37985732ac8SCy Schubert #ifdef CONFIG_DPP
38085732ac8SCy Schubert 	int dpp_init_done;
38185732ac8SCy Schubert 	struct dpp_authentication *dpp_auth;
38285732ac8SCy Schubert 	u8 dpp_allowed_roles;
38385732ac8SCy Schubert 	int dpp_qr_mutual;
38485732ac8SCy Schubert 	int dpp_auth_ok_on_ack;
38585732ac8SCy Schubert 	int dpp_in_response_listen;
38685732ac8SCy Schubert 	struct gas_query_ap *gas;
38785732ac8SCy Schubert 	struct dpp_pkex *dpp_pkex;
38885732ac8SCy Schubert 	struct dpp_bootstrap_info *dpp_pkex_bi;
38985732ac8SCy Schubert 	char *dpp_pkex_code;
39085732ac8SCy Schubert 	char *dpp_pkex_identifier;
39185732ac8SCy Schubert 	char *dpp_pkex_auth_cmd;
39285732ac8SCy Schubert 	char *dpp_configurator_params;
39385732ac8SCy Schubert 	struct os_reltime dpp_last_init;
39485732ac8SCy Schubert 	struct os_reltime dpp_init_iter_start;
39585732ac8SCy Schubert 	unsigned int dpp_init_max_tries;
39685732ac8SCy Schubert 	unsigned int dpp_init_retry_time;
39785732ac8SCy Schubert 	unsigned int dpp_resp_wait_time;
39885732ac8SCy Schubert 	unsigned int dpp_resp_max_tries;
39985732ac8SCy Schubert 	unsigned int dpp_resp_retry_time;
400c1d255d3SCy Schubert #ifdef CONFIG_DPP2
401c1d255d3SCy Schubert 	struct wpabuf *dpp_presence_announcement;
402c1d255d3SCy Schubert 	struct dpp_bootstrap_info *dpp_chirp_bi;
403c1d255d3SCy Schubert 	int dpp_chirp_freq;
404c1d255d3SCy Schubert 	int *dpp_chirp_freqs;
405c1d255d3SCy Schubert 	int dpp_chirp_iter;
406c1d255d3SCy Schubert 	int dpp_chirp_round;
407c1d255d3SCy Schubert 	int dpp_chirp_scan_done;
408c1d255d3SCy Schubert 	int dpp_chirp_listen;
409c1d255d3SCy Schubert #endif /* CONFIG_DPP2 */
41085732ac8SCy Schubert #ifdef CONFIG_TESTING_OPTIONS
41185732ac8SCy Schubert 	char *dpp_config_obj_override;
41285732ac8SCy Schubert 	char *dpp_discovery_override;
41385732ac8SCy Schubert 	char *dpp_groups_override;
41485732ac8SCy Schubert 	unsigned int dpp_ignore_netaccesskey_mismatch:1;
41585732ac8SCy Schubert #endif /* CONFIG_TESTING_OPTIONS */
41685732ac8SCy Schubert #endif /* CONFIG_DPP */
417206b73d0SCy Schubert 
418206b73d0SCy Schubert #ifdef CONFIG_AIRTIME_POLICY
419206b73d0SCy Schubert 	unsigned int num_backlogged_sta;
420206b73d0SCy Schubert 	unsigned int airtime_weight;
421206b73d0SCy Schubert #endif /* CONFIG_AIRTIME_POLICY */
422206b73d0SCy Schubert 
423206b73d0SCy Schubert 	u8 last_1x_eapol_key_replay_counter[8];
424206b73d0SCy Schubert 
425206b73d0SCy Schubert #ifdef CONFIG_SQLITE
426206b73d0SCy Schubert 	sqlite3 *rad_attr_db;
427206b73d0SCy Schubert #endif /* CONFIG_SQLITE */
428c1d255d3SCy Schubert 
429c1d255d3SCy Schubert #ifdef CONFIG_CTRL_IFACE_UDP
430c1d255d3SCy Schubert        unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
431c1d255d3SCy Schubert #endif /* CONFIG_CTRL_IFACE_UDP */
432e28a4053SRui Paulo };
433e28a4053SRui Paulo 
434e28a4053SRui Paulo 
435325151a3SRui Paulo struct hostapd_sta_info {
436325151a3SRui Paulo 	struct dl_list list;
437325151a3SRui Paulo 	u8 addr[ETH_ALEN];
438325151a3SRui Paulo 	struct os_reltime last_seen;
43985732ac8SCy Schubert 	int ssi_signal;
440780fb4a2SCy Schubert #ifdef CONFIG_TAXONOMY
441780fb4a2SCy Schubert 	struct wpabuf *probe_ie_taxonomy;
442780fb4a2SCy Schubert #endif /* CONFIG_TAXONOMY */
443325151a3SRui Paulo };
444325151a3SRui Paulo 
445e28a4053SRui Paulo /**
446e28a4053SRui Paulo  * struct hostapd_iface - hostapd per-interface data structure
447e28a4053SRui Paulo  */
448e28a4053SRui Paulo struct hostapd_iface {
449e28a4053SRui Paulo 	struct hapd_interfaces *interfaces;
450e28a4053SRui Paulo 	void *owner;
451e28a4053SRui Paulo 	char *config_fname;
452e28a4053SRui Paulo 	struct hostapd_config *conf;
4535b9c547cSRui Paulo 	char phy[16]; /* Name of the PHY (radio) */
4545b9c547cSRui Paulo 
4555b9c547cSRui Paulo 	enum hostapd_iface_state {
4565b9c547cSRui Paulo 		HAPD_IFACE_UNINITIALIZED,
4575b9c547cSRui Paulo 		HAPD_IFACE_DISABLED,
4585b9c547cSRui Paulo 		HAPD_IFACE_COUNTRY_UPDATE,
4595b9c547cSRui Paulo 		HAPD_IFACE_ACS,
4605b9c547cSRui Paulo 		HAPD_IFACE_HT_SCAN,
4615b9c547cSRui Paulo 		HAPD_IFACE_DFS,
4625b9c547cSRui Paulo 		HAPD_IFACE_ENABLED
4635b9c547cSRui Paulo 	} state;
4645b9c547cSRui Paulo 
4655b9c547cSRui Paulo #ifdef CONFIG_MESH
4665b9c547cSRui Paulo 	struct mesh_conf *mconf;
4675b9c547cSRui Paulo #endif /* CONFIG_MESH */
468e28a4053SRui Paulo 
469e28a4053SRui Paulo 	size_t num_bss;
470e28a4053SRui Paulo 	struct hostapd_data **bss;
471e28a4053SRui Paulo 
4725b9c547cSRui Paulo 	unsigned int wait_channel_update:1;
4735b9c547cSRui Paulo 	unsigned int cac_started:1;
474325151a3SRui Paulo #ifdef CONFIG_FST
475325151a3SRui Paulo 	struct fst_iface *fst;
476325151a3SRui Paulo 	const struct wpabuf *fst_ies;
477325151a3SRui Paulo #endif /* CONFIG_FST */
4785b9c547cSRui Paulo 
4795b9c547cSRui Paulo 	/*
4805b9c547cSRui Paulo 	 * When set, indicates that the driver will handle the AP
4815b9c547cSRui Paulo 	 * teardown: delete global keys, station keys, and stations.
4825b9c547cSRui Paulo 	 */
4835b9c547cSRui Paulo 	unsigned int driver_ap_teardown:1;
4845b9c547cSRui Paulo 
485780fb4a2SCy Schubert 	/*
486780fb4a2SCy Schubert 	 * When set, indicates that this interface is part of list of
487780fb4a2SCy Schubert 	 * interfaces that need to be started together (synchronously).
488780fb4a2SCy Schubert 	 */
489780fb4a2SCy Schubert 	unsigned int need_to_start_in_sync:1;
490780fb4a2SCy Schubert 
491780fb4a2SCy Schubert 	/* Ready to start but waiting for other interfaces to become ready. */
492780fb4a2SCy Schubert 	unsigned int ready_to_start_in_sync:1;
493780fb4a2SCy Schubert 
494e28a4053SRui Paulo 	int num_ap; /* number of entries in ap_list */
495e28a4053SRui Paulo 	struct ap_info *ap_list; /* AP info list head */
496e28a4053SRui Paulo 	struct ap_info *ap_hash[STA_HASH_SIZE];
497e28a4053SRui Paulo 
4985b9c547cSRui Paulo 	u64 drv_flags;
499c1d255d3SCy Schubert 	u64 drv_flags2;
500f05cddf9SRui Paulo 
501f05cddf9SRui Paulo 	/*
502f05cddf9SRui Paulo 	 * A bitmap of supported protocols for probe response offload. See
503f05cddf9SRui Paulo 	 * struct wpa_driver_capa in driver.h
504f05cddf9SRui Paulo 	 */
505f05cddf9SRui Paulo 	unsigned int probe_resp_offloads;
506f05cddf9SRui Paulo 
5075b9c547cSRui Paulo 	/* extended capabilities supported by the driver */
5085b9c547cSRui Paulo 	const u8 *extended_capa, *extended_capa_mask;
5095b9c547cSRui Paulo 	unsigned int extended_capa_len;
5105b9c547cSRui Paulo 
5115b9c547cSRui Paulo 	unsigned int drv_max_acl_mac_addrs;
5125b9c547cSRui Paulo 
513e28a4053SRui Paulo 	struct hostapd_hw_modes *hw_features;
514e28a4053SRui Paulo 	int num_hw_features;
515e28a4053SRui Paulo 	struct hostapd_hw_modes *current_mode;
516e28a4053SRui Paulo 	/* Rates that are currently used (i.e., filtered copy of
517e28a4053SRui Paulo 	 * current_mode->channels */
518e28a4053SRui Paulo 	int num_rates;
519e28a4053SRui Paulo 	struct hostapd_rate_data *current_rates;
520f05cddf9SRui Paulo 	int *basic_rates;
521e28a4053SRui Paulo 	int freq;
522e28a4053SRui Paulo 
523e28a4053SRui Paulo 	u16 hw_flags;
524e28a4053SRui Paulo 
525e28a4053SRui Paulo 	/* Number of associated Non-ERP stations (i.e., stations using 802.11b
526e28a4053SRui Paulo 	 * in 802.11g BSS) */
527e28a4053SRui Paulo 	int num_sta_non_erp;
528e28a4053SRui Paulo 
529e28a4053SRui Paulo 	/* Number of associated stations that do not support Short Slot Time */
530e28a4053SRui Paulo 	int num_sta_no_short_slot_time;
531e28a4053SRui Paulo 
532e28a4053SRui Paulo 	/* Number of associated stations that do not support Short Preamble */
533e28a4053SRui Paulo 	int num_sta_no_short_preamble;
534e28a4053SRui Paulo 
535e28a4053SRui Paulo 	int olbc; /* Overlapping Legacy BSS Condition */
536e28a4053SRui Paulo 
537e28a4053SRui Paulo 	/* Number of HT associated stations that do not support greenfield */
538e28a4053SRui Paulo 	int num_sta_ht_no_gf;
539e28a4053SRui Paulo 
540e28a4053SRui Paulo 	/* Number of associated non-HT stations */
541e28a4053SRui Paulo 	int num_sta_no_ht;
542e28a4053SRui Paulo 
543e28a4053SRui Paulo 	/* Number of HT associated stations 20 MHz */
544e28a4053SRui Paulo 	int num_sta_ht_20mhz;
545e28a4053SRui Paulo 
5465b9c547cSRui Paulo 	/* Number of HT40 intolerant stations */
5475b9c547cSRui Paulo 	int num_sta_ht40_intolerant;
5485b9c547cSRui Paulo 
549e28a4053SRui Paulo 	/* Overlapping BSS information */
550e28a4053SRui Paulo 	int olbc_ht;
551e28a4053SRui Paulo 
552e28a4053SRui Paulo 	u16 ht_op_mode;
5535b9c547cSRui Paulo 
5545b9c547cSRui Paulo 	/* surveying helpers */
5555b9c547cSRui Paulo 
5565b9c547cSRui Paulo 	/* number of channels surveyed */
5575b9c547cSRui Paulo 	unsigned int chans_surveyed;
5585b9c547cSRui Paulo 
5595b9c547cSRui Paulo 	/* lowest observed noise floor in dBm */
5605b9c547cSRui Paulo 	s8 lowest_nf;
5615b9c547cSRui Paulo 
5625b9c547cSRui Paulo 	/* channel utilization calculation */
5635b9c547cSRui Paulo 	u64 last_channel_time;
5645b9c547cSRui Paulo 	u64 last_channel_time_busy;
5655b9c547cSRui Paulo 	u8 channel_utilization;
5665b9c547cSRui Paulo 
56785732ac8SCy Schubert 	unsigned int chan_util_samples_sum;
56885732ac8SCy Schubert 	unsigned int chan_util_num_sample_periods;
56985732ac8SCy Schubert 	unsigned int chan_util_average;
57085732ac8SCy Schubert 
571780fb4a2SCy Schubert 	/* eCSA IE will be added only if operating class is specified */
572780fb4a2SCy Schubert 	u8 cs_oper_class;
573780fb4a2SCy Schubert 
5745b9c547cSRui Paulo 	unsigned int dfs_cac_ms;
5755b9c547cSRui Paulo 	struct os_reltime dfs_cac_start;
5765b9c547cSRui Paulo 
5775b9c547cSRui Paulo 	/* Latched with the actual secondary channel information and will be
5785b9c547cSRui Paulo 	 * used while juggling between HT20 and HT40 modes. */
5795b9c547cSRui Paulo 	int secondary_ch;
5805b9c547cSRui Paulo 
5815b9c547cSRui Paulo #ifdef CONFIG_ACS
5825b9c547cSRui Paulo 	unsigned int acs_num_completed_scans;
5835b9c547cSRui Paulo #endif /* CONFIG_ACS */
5845b9c547cSRui Paulo 
585e28a4053SRui Paulo 	void (*scan_cb)(struct hostapd_iface *iface);
5865b9c547cSRui Paulo 	int num_ht40_scan_tries;
587325151a3SRui Paulo 
588325151a3SRui Paulo 	struct dl_list sta_seen; /* struct hostapd_sta_info */
589325151a3SRui Paulo 	unsigned int num_sta_seen;
59085732ac8SCy Schubert 
59185732ac8SCy Schubert 	u8 dfs_domain;
592206b73d0SCy Schubert #ifdef CONFIG_AIRTIME_POLICY
593206b73d0SCy Schubert 	unsigned int airtime_quantum;
594206b73d0SCy Schubert #endif /* CONFIG_AIRTIME_POLICY */
595206b73d0SCy Schubert 
596206b73d0SCy Schubert 	/* Previous WMM element information */
597206b73d0SCy Schubert 	struct hostapd_wmm_ac_params prev_wmm[WMM_AC_NUM];
598c1d255d3SCy Schubert 
599c1d255d3SCy Schubert 	int (*enable_iface_cb)(struct hostapd_iface *iface);
600c1d255d3SCy Schubert 	int (*disable_iface_cb)(struct hostapd_iface *iface);
601e28a4053SRui Paulo };
602e28a4053SRui Paulo 
603e28a4053SRui Paulo /* hostapd.c */
604f05cddf9SRui Paulo int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
605f05cddf9SRui Paulo 			       int (*cb)(struct hostapd_iface *iface,
606f05cddf9SRui Paulo 					 void *ctx), void *ctx);
607e28a4053SRui Paulo int hostapd_reload_config(struct hostapd_iface *iface);
60885732ac8SCy Schubert void hostapd_reconfig_encryption(struct hostapd_data *hapd);
609e28a4053SRui Paulo struct hostapd_data *
610e28a4053SRui Paulo hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
611e28a4053SRui Paulo 		       struct hostapd_config *conf,
612e28a4053SRui Paulo 		       struct hostapd_bss_config *bss);
613e28a4053SRui Paulo int hostapd_setup_interface(struct hostapd_iface *iface);
614e28a4053SRui Paulo int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
615e28a4053SRui Paulo void hostapd_interface_deinit(struct hostapd_iface *iface);
616e28a4053SRui Paulo void hostapd_interface_free(struct hostapd_iface *iface);
617780fb4a2SCy Schubert struct hostapd_iface * hostapd_alloc_iface(void);
6185b9c547cSRui Paulo struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
6195b9c547cSRui Paulo 				    const char *config_file);
6205b9c547cSRui Paulo struct hostapd_iface *
6215b9c547cSRui Paulo hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
6225b9c547cSRui Paulo 			   const char *config_fname, int debug);
623e28a4053SRui Paulo void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
624e28a4053SRui Paulo 			   int reassoc);
625f05cddf9SRui Paulo void hostapd_interface_deinit_free(struct hostapd_iface *iface);
626f05cddf9SRui Paulo int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
627f05cddf9SRui Paulo int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
628f05cddf9SRui Paulo int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
629c1d255d3SCy Schubert void hostapd_bss_deinit_no_free(struct hostapd_data *hapd);
630c1d255d3SCy Schubert void hostapd_free_hapd_data(struct hostapd_data *hapd);
631c1d255d3SCy Schubert void hostapd_cleanup_iface_partial(struct hostapd_iface *iface);
632f05cddf9SRui Paulo int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
633f05cddf9SRui Paulo int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
6345b9c547cSRui Paulo void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
6355b9c547cSRui Paulo void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
6365b9c547cSRui Paulo const char * hostapd_state_text(enum hostapd_iface_state s);
637780fb4a2SCy Schubert int hostapd_csa_in_progress(struct hostapd_iface *iface);
638c1d255d3SCy Schubert void hostapd_chan_switch_config(struct hostapd_data *hapd,
639c1d255d3SCy Schubert 				struct hostapd_freq_params *freq_params);
6405b9c547cSRui Paulo int hostapd_switch_channel(struct hostapd_data *hapd,
6415b9c547cSRui Paulo 			   struct csa_settings *settings);
6425b9c547cSRui Paulo void
6435b9c547cSRui Paulo hostapd_switch_channel_fallback(struct hostapd_iface *iface,
6445b9c547cSRui Paulo 				const struct hostapd_freq_params *freq_params);
6455b9c547cSRui Paulo void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
646325151a3SRui Paulo void hostapd_periodic_iface(struct hostapd_iface *iface);
64785732ac8SCy Schubert int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
648c1d255d3SCy Schubert void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx);
649e28a4053SRui Paulo 
650e28a4053SRui Paulo /* utils.c */
651e28a4053SRui Paulo int hostapd_register_probereq_cb(struct hostapd_data *hapd,
652e28a4053SRui Paulo 				 int (*cb)(void *ctx, const u8 *sa,
653f05cddf9SRui Paulo 					   const u8 *da, const u8 *bssid,
654f05cddf9SRui Paulo 					   const u8 *ie, size_t ie_len,
655f05cddf9SRui Paulo 					   int ssi_signal),
656e28a4053SRui Paulo 				 void *ctx);
657e28a4053SRui Paulo void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
658e28a4053SRui Paulo 
659e28a4053SRui Paulo /* drv_callbacks.c (TODO: move to somewhere else?) */
66085732ac8SCy Schubert void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd,
66185732ac8SCy Schubert 				      struct sta_info *sta);
662e28a4053SRui Paulo int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
663f05cddf9SRui Paulo 			const u8 *ie, size_t ielen, int reassoc);
664e28a4053SRui Paulo void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
665f05cddf9SRui Paulo void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
6665b9c547cSRui Paulo void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
6675b9c547cSRui Paulo 					 const u8 *addr, int reason_code);
668f05cddf9SRui Paulo int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
669f05cddf9SRui Paulo 			 const u8 *bssid, const u8 *ie, size_t ie_len,
670f05cddf9SRui Paulo 			 int ssi_signal);
671f05cddf9SRui Paulo void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
672206b73d0SCy Schubert 			     int offset, int width, int cf1, int cf2,
673206b73d0SCy Schubert 			     int finished);
674780fb4a2SCy Schubert struct survey_results;
675780fb4a2SCy Schubert void hostapd_event_get_survey(struct hostapd_iface *iface,
676780fb4a2SCy Schubert 			      struct survey_results *survey_results);
677780fb4a2SCy Schubert void hostapd_acs_channel_selected(struct hostapd_data *hapd,
678780fb4a2SCy Schubert 				  struct acs_selected_channels *acs_res);
679f05cddf9SRui Paulo 
680f05cddf9SRui Paulo const struct hostapd_eap_user *
681f05cddf9SRui Paulo hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
682f05cddf9SRui Paulo 		     size_t identity_len, int phase2);
683e28a4053SRui Paulo 
684325151a3SRui Paulo struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces,
685325151a3SRui Paulo 					const char *ifname);
68685732ac8SCy Schubert void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr,
68785732ac8SCy Schubert 				      enum smps_mode smps_mode,
68885732ac8SCy Schubert 				      enum chan_width chan_width, u8 rx_nss);
689325151a3SRui Paulo 
690325151a3SRui Paulo #ifdef CONFIG_FST
691325151a3SRui Paulo void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
692325151a3SRui Paulo 				struct fst_wpa_obj *iface_obj);
693325151a3SRui Paulo #endif /* CONFIG_FST */
694325151a3SRui Paulo 
695e28a4053SRui Paulo #endif /* HOSTAPD_H */
696