xref: /freebsd/contrib/wpa/src/ap/hostapd.h (revision 206b73d0429edb7c49b612537544e677fa568e83)
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 
12*206b73d0SCy Schubert #ifdef CONFIG_SQLITE
13*206b73d0SCy Schubert #include <sqlite3.h>
14*206b73d0SCy Schubert #endif /* CONFIG_SQLITE */
15*206b73d0SCy 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 
41f05cddf9SRui Paulo struct hostapd_iface;
42f05cddf9SRui Paulo 
43f05cddf9SRui Paulo struct hapd_interfaces {
44f05cddf9SRui Paulo 	int (*reload_config)(struct hostapd_iface *iface);
45f05cddf9SRui Paulo 	struct hostapd_config * (*config_read_cb)(const char *config_fname);
46f05cddf9SRui Paulo 	int (*ctrl_iface_init)(struct hostapd_data *hapd);
47f05cddf9SRui Paulo 	void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
48f05cddf9SRui Paulo 	int (*for_each_interface)(struct hapd_interfaces *interfaces,
49f05cddf9SRui Paulo 				  int (*cb)(struct hostapd_iface *iface,
50f05cddf9SRui Paulo 					    void *ctx), void *ctx);
51f05cddf9SRui Paulo 	int (*driver_init)(struct hostapd_iface *iface);
52f05cddf9SRui Paulo 
53f05cddf9SRui Paulo 	size_t count;
54f05cddf9SRui Paulo 	int global_ctrl_sock;
55780fb4a2SCy Schubert 	struct dl_list global_ctrl_dst;
56f05cddf9SRui Paulo 	char *global_iface_path;
57f05cddf9SRui Paulo 	char *global_iface_name;
585b9c547cSRui Paulo #ifndef CONFIG_NATIVE_WINDOWS
595b9c547cSRui Paulo 	gid_t ctrl_iface_group;
605b9c547cSRui Paulo #endif /* CONFIG_NATIVE_WINDOWS */
61f05cddf9SRui Paulo 	struct hostapd_iface **iface;
625b9c547cSRui Paulo 
635b9c547cSRui Paulo 	size_t terminate_on_error;
64325151a3SRui Paulo #ifndef CONFIG_NO_VLAN
65325151a3SRui Paulo 	struct dynamic_iface *vlan_priv;
66325151a3SRui Paulo #endif /* CONFIG_NO_VLAN */
6785732ac8SCy Schubert #ifdef CONFIG_ETH_P_OUI
6885732ac8SCy Schubert 	struct dl_list eth_p_oui; /* OUI Extended EtherType handlers */
6985732ac8SCy Schubert #endif /* CONFIG_ETH_P_OUI */
70780fb4a2SCy Schubert 	int eloop_initialized;
7185732ac8SCy Schubert 
7285732ac8SCy Schubert #ifdef CONFIG_DPP
734bc52338SCy Schubert 	struct dpp_global *dpp;
7485732ac8SCy Schubert #endif /* CONFIG_DPP */
75f05cddf9SRui Paulo };
76f05cddf9SRui Paulo 
775b9c547cSRui Paulo enum hostapd_chan_status {
785b9c547cSRui Paulo 	HOSTAPD_CHAN_VALID = 0, /* channel is ready */
795b9c547cSRui Paulo 	HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */
805b9c547cSRui Paulo 	HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */
815b9c547cSRui Paulo };
82e28a4053SRui Paulo 
83e28a4053SRui Paulo struct hostapd_probereq_cb {
84f05cddf9SRui Paulo 	int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
85f05cddf9SRui Paulo 		  const u8 *ie, size_t ie_len, int ssi_signal);
86e28a4053SRui Paulo 	void *ctx;
87e28a4053SRui Paulo };
88e28a4053SRui Paulo 
89e28a4053SRui Paulo #define HOSTAPD_RATE_BASIC 0x00000001
90e28a4053SRui Paulo 
91e28a4053SRui Paulo struct hostapd_rate_data {
92e28a4053SRui Paulo 	int rate; /* rate in 100 kbps */
93e28a4053SRui Paulo 	int flags; /* HOSTAPD_RATE_ flags */
94e28a4053SRui Paulo };
95e28a4053SRui Paulo 
96e28a4053SRui Paulo struct hostapd_frame_info {
9785732ac8SCy Schubert 	unsigned int freq;
98e28a4053SRui Paulo 	u32 channel;
99e28a4053SRui Paulo 	u32 datarate;
100f05cddf9SRui Paulo 	int ssi_signal; /* dBm */
101e28a4053SRui Paulo };
102e28a4053SRui Paulo 
1035b9c547cSRui Paulo enum wps_status {
1045b9c547cSRui Paulo 	WPS_STATUS_SUCCESS = 1,
1055b9c547cSRui Paulo 	WPS_STATUS_FAILURE
1065b9c547cSRui Paulo };
1075b9c547cSRui Paulo 
1085b9c547cSRui Paulo enum pbc_status {
1095b9c547cSRui Paulo 	WPS_PBC_STATUS_DISABLE,
1105b9c547cSRui Paulo 	WPS_PBC_STATUS_ACTIVE,
1115b9c547cSRui Paulo 	WPS_PBC_STATUS_TIMEOUT,
1125b9c547cSRui Paulo 	WPS_PBC_STATUS_OVERLAP
1135b9c547cSRui Paulo };
1145b9c547cSRui Paulo 
1155b9c547cSRui Paulo struct wps_stat {
1165b9c547cSRui Paulo 	enum wps_status status;
1175b9c547cSRui Paulo 	enum wps_error_indication failure_reason;
1185b9c547cSRui Paulo 	enum pbc_status pbc_status;
1195b9c547cSRui Paulo 	u8 peer_addr[ETH_ALEN];
1205b9c547cSRui Paulo };
1215b9c547cSRui Paulo 
122780fb4a2SCy Schubert struct hostapd_neighbor_entry {
123780fb4a2SCy Schubert 	struct dl_list list;
124780fb4a2SCy Schubert 	u8 bssid[ETH_ALEN];
125780fb4a2SCy Schubert 	struct wpa_ssid_value ssid;
126780fb4a2SCy Schubert 	struct wpabuf *nr;
127780fb4a2SCy Schubert 	struct wpabuf *lci;
128780fb4a2SCy Schubert 	struct wpabuf *civic;
129780fb4a2SCy Schubert 	/* LCI update time */
130780fb4a2SCy Schubert 	struct os_time lci_date;
13185732ac8SCy Schubert 	int stationary;
132780fb4a2SCy Schubert };
133e28a4053SRui Paulo 
1344bc52338SCy Schubert struct hostapd_sae_commit_queue {
1354bc52338SCy Schubert 	struct dl_list list;
1364bc52338SCy Schubert 	int rssi;
1374bc52338SCy Schubert 	size_t len;
1384bc52338SCy Schubert 	u8 msg[];
1394bc52338SCy Schubert };
1404bc52338SCy Schubert 
141e28a4053SRui Paulo /**
142e28a4053SRui Paulo  * struct hostapd_data - hostapd per-BSS data structure
143e28a4053SRui Paulo  */
144e28a4053SRui Paulo struct hostapd_data {
145e28a4053SRui Paulo 	struct hostapd_iface *iface;
146e28a4053SRui Paulo 	struct hostapd_config *iconf;
147e28a4053SRui Paulo 	struct hostapd_bss_config *conf;
148e28a4053SRui Paulo 	int interface_added; /* virtual interface added for this BSS */
1495b9c547cSRui Paulo 	unsigned int started:1;
1505b9c547cSRui Paulo 	unsigned int disabled:1;
1515b9c547cSRui Paulo 	unsigned int reenable_beacon:1;
152e28a4053SRui Paulo 
153e28a4053SRui Paulo 	u8 own_addr[ETH_ALEN];
154e28a4053SRui Paulo 
155e28a4053SRui Paulo 	int num_sta; /* number of entries in sta_list */
156e28a4053SRui Paulo 	struct sta_info *sta_list; /* STA info list head */
157e28a4053SRui Paulo #define STA_HASH_SIZE 256
158e28a4053SRui Paulo #define STA_HASH(sta) (sta[5])
159e28a4053SRui Paulo 	struct sta_info *sta_hash[STA_HASH_SIZE];
160e28a4053SRui Paulo 
161e28a4053SRui Paulo 	/*
162e28a4053SRui Paulo 	 * Bitfield for indicating which AIDs are allocated. Only AID values
163e28a4053SRui Paulo 	 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
164e28a4053SRui Paulo 	 * 1.
165e28a4053SRui Paulo 	 */
166e28a4053SRui Paulo #define AID_WORDS ((2008 + 31) / 32)
167e28a4053SRui Paulo 	u32 sta_aid[AID_WORDS];
168e28a4053SRui Paulo 
169e28a4053SRui Paulo 	const struct wpa_driver_ops *driver;
170e28a4053SRui Paulo 	void *drv_priv;
171e28a4053SRui Paulo 
172e28a4053SRui Paulo 	void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
173e28a4053SRui Paulo 				 struct sta_info *sta, int reassoc);
174e28a4053SRui Paulo 
175e28a4053SRui Paulo 	void *msg_ctx; /* ctx for wpa_msg() calls */
176f05cddf9SRui Paulo 	void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
177e28a4053SRui Paulo 
178e28a4053SRui Paulo 	struct radius_client_data *radius;
179780fb4a2SCy Schubert 	u64 acct_session_id;
180f05cddf9SRui Paulo 	struct radius_das_data *radius_das;
181e28a4053SRui Paulo 
182e28a4053SRui Paulo 	struct iapp_data *iapp;
183e28a4053SRui Paulo 
184e28a4053SRui Paulo 	struct hostapd_cached_radius_acl *acl_cache;
185e28a4053SRui Paulo 	struct hostapd_acl_query_data *acl_queries;
186e28a4053SRui Paulo 
187e28a4053SRui Paulo 	struct wpa_authenticator *wpa_auth;
188e28a4053SRui Paulo 	struct eapol_authenticator *eapol_auth;
189e28a4053SRui Paulo 
190e28a4053SRui Paulo 	struct rsn_preauth_interface *preauth_iface;
1915b9c547cSRui Paulo 	struct os_reltime michael_mic_failure;
192e28a4053SRui Paulo 	int michael_mic_failures;
193e28a4053SRui Paulo 	int tkip_countermeasures;
194e28a4053SRui Paulo 
195e28a4053SRui Paulo 	int ctrl_sock;
196780fb4a2SCy Schubert 	struct dl_list ctrl_dst;
197e28a4053SRui Paulo 
198e28a4053SRui Paulo 	void *ssl_ctx;
199e28a4053SRui Paulo 	void *eap_sim_db_priv;
200e28a4053SRui Paulo 	struct radius_server_data *radius_srv;
2015b9c547cSRui Paulo 	struct dl_list erp_keys; /* struct eap_server_erp_key */
202e28a4053SRui Paulo 
203e28a4053SRui Paulo 	int parameter_set_count;
204e28a4053SRui Paulo 
205f05cddf9SRui Paulo 	/* Time Advertisement */
206f05cddf9SRui Paulo 	u8 time_update_counter;
207f05cddf9SRui Paulo 	struct wpabuf *time_adv;
208f05cddf9SRui Paulo 
209e28a4053SRui Paulo #ifdef CONFIG_FULL_DYNAMIC_VLAN
210e28a4053SRui Paulo 	struct full_dynamic_vlan *full_dynamic_vlan;
211e28a4053SRui Paulo #endif /* CONFIG_FULL_DYNAMIC_VLAN */
212e28a4053SRui Paulo 
213e28a4053SRui Paulo 	struct l2_packet_data *l2;
21485732ac8SCy Schubert 
21585732ac8SCy Schubert #ifdef CONFIG_IEEE80211R_AP
21685732ac8SCy Schubert 	struct dl_list l2_queue;
21785732ac8SCy Schubert 	struct dl_list l2_oui_queue;
21885732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_pull;
21985732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_resp;
22085732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_push;
22185732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_sreq;
22285732ac8SCy Schubert 	struct eth_p_oui_ctx *oui_sresp;
22385732ac8SCy Schubert #endif /* CONFIG_IEEE80211R_AP */
22485732ac8SCy Schubert 
225e28a4053SRui Paulo 	struct wps_context *wps;
226e28a4053SRui Paulo 
227f05cddf9SRui Paulo 	int beacon_set_done;
228e28a4053SRui Paulo 	struct wpabuf *wps_beacon_ie;
229e28a4053SRui Paulo 	struct wpabuf *wps_probe_resp_ie;
230e28a4053SRui Paulo #ifdef CONFIG_WPS
231e28a4053SRui Paulo 	unsigned int ap_pin_failures;
232f05cddf9SRui Paulo 	unsigned int ap_pin_failures_consecutive;
233e28a4053SRui Paulo 	struct upnp_wps_device_sm *wps_upnp;
234e28a4053SRui Paulo 	unsigned int ap_pin_lockout_time;
2355b9c547cSRui Paulo 
2365b9c547cSRui Paulo 	struct wps_stat wps_stats;
237e28a4053SRui Paulo #endif /* CONFIG_WPS */
238e28a4053SRui Paulo 
239*206b73d0SCy Schubert #ifdef CONFIG_MACSEC
240*206b73d0SCy Schubert 	struct ieee802_1x_kay *kay;
241*206b73d0SCy Schubert #endif /* CONFIG_MACSEC */
242*206b73d0SCy Schubert 
243e28a4053SRui Paulo 	struct hostapd_probereq_cb *probereq_cb;
244e28a4053SRui Paulo 	size_t num_probereq_cb;
245e28a4053SRui Paulo 
246e28a4053SRui Paulo 	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
247e28a4053SRui Paulo 				 int freq);
248e28a4053SRui Paulo 	void *public_action_cb_ctx;
2495b9c547cSRui Paulo 	void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
2505b9c547cSRui Paulo 				  int freq);
2515b9c547cSRui Paulo 	void *public_action_cb2_ctx;
252e28a4053SRui Paulo 
253f05cddf9SRui Paulo 	int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
254f05cddf9SRui Paulo 				int freq);
255f05cddf9SRui Paulo 	void *vendor_action_cb_ctx;
256f05cddf9SRui Paulo 
257e28a4053SRui Paulo 	void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
258e28a4053SRui Paulo 				   const u8 *uuid_e);
259e28a4053SRui Paulo 	void *wps_reg_success_cb_ctx;
260f05cddf9SRui Paulo 
261f05cddf9SRui Paulo 	void (*wps_event_cb)(void *ctx, enum wps_event event,
262f05cddf9SRui Paulo 			     union wps_event_data *data);
263f05cddf9SRui Paulo 	void *wps_event_cb_ctx;
264f05cddf9SRui Paulo 
265f05cddf9SRui Paulo 	void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
266f05cddf9SRui Paulo 				  int authorized, const u8 *p2p_dev_addr);
267f05cddf9SRui Paulo 	void *sta_authorized_cb_ctx;
268f05cddf9SRui Paulo 
269f05cddf9SRui Paulo 	void (*setup_complete_cb)(void *ctx);
270f05cddf9SRui Paulo 	void *setup_complete_cb_ctx;
271f05cddf9SRui Paulo 
2725b9c547cSRui Paulo 	void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
2735b9c547cSRui Paulo 			   const u8 *p2p_dev_addr, const u8 *psk,
2745b9c547cSRui Paulo 			   size_t psk_len);
2755b9c547cSRui Paulo 	void *new_psk_cb_ctx;
2765b9c547cSRui Paulo 
2775b9c547cSRui Paulo 	/* channel switch parameters */
2785b9c547cSRui Paulo 	struct hostapd_freq_params cs_freq_params;
2795b9c547cSRui Paulo 	u8 cs_count;
2805b9c547cSRui Paulo 	int cs_block_tx;
2815b9c547cSRui Paulo 	unsigned int cs_c_off_beacon;
2825b9c547cSRui Paulo 	unsigned int cs_c_off_proberesp;
2835b9c547cSRui Paulo 	int csa_in_progress;
284780fb4a2SCy Schubert 	unsigned int cs_c_off_ecsa_beacon;
285780fb4a2SCy Schubert 	unsigned int cs_c_off_ecsa_proberesp;
2865b9c547cSRui Paulo 
287f05cddf9SRui Paulo #ifdef CONFIG_P2P
288f05cddf9SRui Paulo 	struct p2p_data *p2p;
289f05cddf9SRui Paulo 	struct p2p_group *p2p_group;
290f05cddf9SRui Paulo 	struct wpabuf *p2p_beacon_ie;
291f05cddf9SRui Paulo 	struct wpabuf *p2p_probe_resp_ie;
292f05cddf9SRui Paulo 
293f05cddf9SRui Paulo 	/* Number of non-P2P association stations */
294f05cddf9SRui Paulo 	int num_sta_no_p2p;
295f05cddf9SRui Paulo 
296f05cddf9SRui Paulo 	/* Periodic NoA (used only when no non-P2P clients in the group) */
297f05cddf9SRui Paulo 	int noa_enabled;
298f05cddf9SRui Paulo 	int noa_start;
299f05cddf9SRui Paulo 	int noa_duration;
300f05cddf9SRui Paulo #endif /* CONFIG_P2P */
3015b9c547cSRui Paulo #ifdef CONFIG_PROXYARP
3025b9c547cSRui Paulo 	struct l2_packet_data *sock_dhcp;
3035b9c547cSRui Paulo 	struct l2_packet_data *sock_ndisc;
3045b9c547cSRui Paulo #endif /* CONFIG_PROXYARP */
3055b9c547cSRui Paulo #ifdef CONFIG_MESH
3065b9c547cSRui Paulo 	int num_plinks;
3075b9c547cSRui Paulo 	int max_plinks;
308780fb4a2SCy Schubert 	void (*mesh_sta_free_cb)(struct hostapd_data *hapd,
309780fb4a2SCy Schubert 				 struct sta_info *sta);
3105b9c547cSRui Paulo 	struct wpabuf *mesh_pending_auth;
3115b9c547cSRui Paulo 	struct os_reltime mesh_pending_auth_time;
312780fb4a2SCy Schubert 	u8 mesh_required_peer[ETH_ALEN];
3135b9c547cSRui Paulo #endif /* CONFIG_MESH */
314f05cddf9SRui Paulo 
315f05cddf9SRui Paulo #ifdef CONFIG_SQLITE
316f05cddf9SRui Paulo 	struct hostapd_eap_user tmp_eap_user;
317f05cddf9SRui Paulo #endif /* CONFIG_SQLITE */
3185b9c547cSRui Paulo 
3195b9c547cSRui Paulo #ifdef CONFIG_SAE
3205b9c547cSRui Paulo 	/** Key used for generating SAE anti-clogging tokens */
3215b9c547cSRui Paulo 	u8 sae_token_key[8];
3225b9c547cSRui Paulo 	struct os_reltime last_sae_token_key_update;
3234bc52338SCy Schubert 	u16 sae_token_idx;
3244bc52338SCy Schubert 	u16 sae_pending_token_idx[256];
325325151a3SRui Paulo 	int dot11RSNASAERetransPeriod; /* msec */
3264bc52338SCy Schubert 	struct dl_list sae_commit_queue; /* struct hostapd_sae_commit_queue */
3275b9c547cSRui Paulo #endif /* CONFIG_SAE */
3285b9c547cSRui Paulo 
3295b9c547cSRui Paulo #ifdef CONFIG_TESTING_OPTIONS
3305b9c547cSRui Paulo 	unsigned int ext_mgmt_frame_handling:1;
3315b9c547cSRui Paulo 	unsigned int ext_eapol_frame_io:1;
3325b9c547cSRui Paulo 
3335b9c547cSRui Paulo 	struct l2_packet_data *l2_test;
33485732ac8SCy Schubert 
33585732ac8SCy Schubert 	enum wpa_alg last_gtk_alg;
33685732ac8SCy Schubert 	int last_gtk_key_idx;
33785732ac8SCy Schubert 	u8 last_gtk[WPA_GTK_MAX_LEN];
33885732ac8SCy Schubert 	size_t last_gtk_len;
33985732ac8SCy Schubert 
34085732ac8SCy Schubert #ifdef CONFIG_IEEE80211W
34185732ac8SCy Schubert 	enum wpa_alg last_igtk_alg;
34285732ac8SCy Schubert 	int last_igtk_key_idx;
34385732ac8SCy Schubert 	u8 last_igtk[WPA_IGTK_MAX_LEN];
34485732ac8SCy Schubert 	size_t last_igtk_len;
34585732ac8SCy Schubert #endif /* CONFIG_IEEE80211W */
3465b9c547cSRui Paulo #endif /* CONFIG_TESTING_OPTIONS */
347780fb4a2SCy Schubert 
348780fb4a2SCy Schubert #ifdef CONFIG_MBO
349780fb4a2SCy Schubert 	unsigned int mbo_assoc_disallow;
350780fb4a2SCy Schubert #endif /* CONFIG_MBO */
351780fb4a2SCy Schubert 
352780fb4a2SCy Schubert 	struct dl_list nr_db;
353780fb4a2SCy Schubert 
35485732ac8SCy Schubert 	u8 beacon_req_token;
355780fb4a2SCy Schubert 	u8 lci_req_token;
356780fb4a2SCy Schubert 	u8 range_req_token;
357780fb4a2SCy Schubert 	unsigned int lci_req_active:1;
358780fb4a2SCy Schubert 	unsigned int range_req_active:1;
35985732ac8SCy Schubert 
36085732ac8SCy Schubert 	int dhcp_sock; /* UDP socket used with the DHCP server */
36185732ac8SCy Schubert 
36285732ac8SCy Schubert #ifdef CONFIG_DPP
36385732ac8SCy Schubert 	int dpp_init_done;
36485732ac8SCy Schubert 	struct dpp_authentication *dpp_auth;
36585732ac8SCy Schubert 	u8 dpp_allowed_roles;
36685732ac8SCy Schubert 	int dpp_qr_mutual;
36785732ac8SCy Schubert 	int dpp_auth_ok_on_ack;
36885732ac8SCy Schubert 	int dpp_in_response_listen;
36985732ac8SCy Schubert 	struct gas_query_ap *gas;
37085732ac8SCy Schubert 	struct dpp_pkex *dpp_pkex;
37185732ac8SCy Schubert 	struct dpp_bootstrap_info *dpp_pkex_bi;
37285732ac8SCy Schubert 	char *dpp_pkex_code;
37385732ac8SCy Schubert 	char *dpp_pkex_identifier;
37485732ac8SCy Schubert 	char *dpp_pkex_auth_cmd;
37585732ac8SCy Schubert 	char *dpp_configurator_params;
37685732ac8SCy Schubert 	struct os_reltime dpp_last_init;
37785732ac8SCy Schubert 	struct os_reltime dpp_init_iter_start;
37885732ac8SCy Schubert 	unsigned int dpp_init_max_tries;
37985732ac8SCy Schubert 	unsigned int dpp_init_retry_time;
38085732ac8SCy Schubert 	unsigned int dpp_resp_wait_time;
38185732ac8SCy Schubert 	unsigned int dpp_resp_max_tries;
38285732ac8SCy Schubert 	unsigned int dpp_resp_retry_time;
38385732ac8SCy Schubert #ifdef CONFIG_TESTING_OPTIONS
38485732ac8SCy Schubert 	char *dpp_config_obj_override;
38585732ac8SCy Schubert 	char *dpp_discovery_override;
38685732ac8SCy Schubert 	char *dpp_groups_override;
38785732ac8SCy Schubert 	unsigned int dpp_ignore_netaccesskey_mismatch:1;
38885732ac8SCy Schubert #endif /* CONFIG_TESTING_OPTIONS */
38985732ac8SCy Schubert #endif /* CONFIG_DPP */
390*206b73d0SCy Schubert 
391*206b73d0SCy Schubert #ifdef CONFIG_AIRTIME_POLICY
392*206b73d0SCy Schubert 	unsigned int num_backlogged_sta;
393*206b73d0SCy Schubert 	unsigned int airtime_weight;
394*206b73d0SCy Schubert #endif /* CONFIG_AIRTIME_POLICY */
395*206b73d0SCy Schubert 
396*206b73d0SCy Schubert 	u8 last_1x_eapol_key_replay_counter[8];
397*206b73d0SCy Schubert 
398*206b73d0SCy Schubert #ifdef CONFIG_SQLITE
399*206b73d0SCy Schubert 	sqlite3 *rad_attr_db;
400*206b73d0SCy Schubert #endif /* CONFIG_SQLITE */
401e28a4053SRui Paulo };
402e28a4053SRui Paulo 
403e28a4053SRui Paulo 
404325151a3SRui Paulo struct hostapd_sta_info {
405325151a3SRui Paulo 	struct dl_list list;
406325151a3SRui Paulo 	u8 addr[ETH_ALEN];
407325151a3SRui Paulo 	struct os_reltime last_seen;
40885732ac8SCy Schubert 	int ssi_signal;
409780fb4a2SCy Schubert #ifdef CONFIG_TAXONOMY
410780fb4a2SCy Schubert 	struct wpabuf *probe_ie_taxonomy;
411780fb4a2SCy Schubert #endif /* CONFIG_TAXONOMY */
412325151a3SRui Paulo };
413325151a3SRui Paulo 
414e28a4053SRui Paulo /**
415e28a4053SRui Paulo  * struct hostapd_iface - hostapd per-interface data structure
416e28a4053SRui Paulo  */
417e28a4053SRui Paulo struct hostapd_iface {
418e28a4053SRui Paulo 	struct hapd_interfaces *interfaces;
419e28a4053SRui Paulo 	void *owner;
420e28a4053SRui Paulo 	char *config_fname;
421e28a4053SRui Paulo 	struct hostapd_config *conf;
4225b9c547cSRui Paulo 	char phy[16]; /* Name of the PHY (radio) */
4235b9c547cSRui Paulo 
4245b9c547cSRui Paulo 	enum hostapd_iface_state {
4255b9c547cSRui Paulo 		HAPD_IFACE_UNINITIALIZED,
4265b9c547cSRui Paulo 		HAPD_IFACE_DISABLED,
4275b9c547cSRui Paulo 		HAPD_IFACE_COUNTRY_UPDATE,
4285b9c547cSRui Paulo 		HAPD_IFACE_ACS,
4295b9c547cSRui Paulo 		HAPD_IFACE_HT_SCAN,
4305b9c547cSRui Paulo 		HAPD_IFACE_DFS,
4315b9c547cSRui Paulo 		HAPD_IFACE_ENABLED
4325b9c547cSRui Paulo 	} state;
4335b9c547cSRui Paulo 
4345b9c547cSRui Paulo #ifdef CONFIG_MESH
4355b9c547cSRui Paulo 	struct mesh_conf *mconf;
4365b9c547cSRui Paulo #endif /* CONFIG_MESH */
437e28a4053SRui Paulo 
438e28a4053SRui Paulo 	size_t num_bss;
439e28a4053SRui Paulo 	struct hostapd_data **bss;
440e28a4053SRui Paulo 
4415b9c547cSRui Paulo 	unsigned int wait_channel_update:1;
4425b9c547cSRui Paulo 	unsigned int cac_started:1;
443325151a3SRui Paulo #ifdef CONFIG_FST
444325151a3SRui Paulo 	struct fst_iface *fst;
445325151a3SRui Paulo 	const struct wpabuf *fst_ies;
446325151a3SRui Paulo #endif /* CONFIG_FST */
4475b9c547cSRui Paulo 
4485b9c547cSRui Paulo 	/*
4495b9c547cSRui Paulo 	 * When set, indicates that the driver will handle the AP
4505b9c547cSRui Paulo 	 * teardown: delete global keys, station keys, and stations.
4515b9c547cSRui Paulo 	 */
4525b9c547cSRui Paulo 	unsigned int driver_ap_teardown:1;
4535b9c547cSRui Paulo 
454780fb4a2SCy Schubert 	/*
455780fb4a2SCy Schubert 	 * When set, indicates that this interface is part of list of
456780fb4a2SCy Schubert 	 * interfaces that need to be started together (synchronously).
457780fb4a2SCy Schubert 	 */
458780fb4a2SCy Schubert 	unsigned int need_to_start_in_sync:1;
459780fb4a2SCy Schubert 
460780fb4a2SCy Schubert 	/* Ready to start but waiting for other interfaces to become ready. */
461780fb4a2SCy Schubert 	unsigned int ready_to_start_in_sync:1;
462780fb4a2SCy Schubert 
463e28a4053SRui Paulo 	int num_ap; /* number of entries in ap_list */
464e28a4053SRui Paulo 	struct ap_info *ap_list; /* AP info list head */
465e28a4053SRui Paulo 	struct ap_info *ap_hash[STA_HASH_SIZE];
466e28a4053SRui Paulo 
4675b9c547cSRui Paulo 	u64 drv_flags;
4685b9c547cSRui Paulo 
4695b9c547cSRui Paulo 	/* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */
4705b9c547cSRui Paulo 	unsigned int smps_modes;
471f05cddf9SRui Paulo 
472f05cddf9SRui Paulo 	/*
473f05cddf9SRui Paulo 	 * A bitmap of supported protocols for probe response offload. See
474f05cddf9SRui Paulo 	 * struct wpa_driver_capa in driver.h
475f05cddf9SRui Paulo 	 */
476f05cddf9SRui Paulo 	unsigned int probe_resp_offloads;
477f05cddf9SRui Paulo 
4785b9c547cSRui Paulo 	/* extended capabilities supported by the driver */
4795b9c547cSRui Paulo 	const u8 *extended_capa, *extended_capa_mask;
4805b9c547cSRui Paulo 	unsigned int extended_capa_len;
4815b9c547cSRui Paulo 
4825b9c547cSRui Paulo 	unsigned int drv_max_acl_mac_addrs;
4835b9c547cSRui Paulo 
484e28a4053SRui Paulo 	struct hostapd_hw_modes *hw_features;
485e28a4053SRui Paulo 	int num_hw_features;
486e28a4053SRui Paulo 	struct hostapd_hw_modes *current_mode;
487e28a4053SRui Paulo 	/* Rates that are currently used (i.e., filtered copy of
488e28a4053SRui Paulo 	 * current_mode->channels */
489e28a4053SRui Paulo 	int num_rates;
490e28a4053SRui Paulo 	struct hostapd_rate_data *current_rates;
491f05cddf9SRui Paulo 	int *basic_rates;
492e28a4053SRui Paulo 	int freq;
493e28a4053SRui Paulo 
494e28a4053SRui Paulo 	u16 hw_flags;
495e28a4053SRui Paulo 
496e28a4053SRui Paulo 	/* Number of associated Non-ERP stations (i.e., stations using 802.11b
497e28a4053SRui Paulo 	 * in 802.11g BSS) */
498e28a4053SRui Paulo 	int num_sta_non_erp;
499e28a4053SRui Paulo 
500e28a4053SRui Paulo 	/* Number of associated stations that do not support Short Slot Time */
501e28a4053SRui Paulo 	int num_sta_no_short_slot_time;
502e28a4053SRui Paulo 
503e28a4053SRui Paulo 	/* Number of associated stations that do not support Short Preamble */
504e28a4053SRui Paulo 	int num_sta_no_short_preamble;
505e28a4053SRui Paulo 
506e28a4053SRui Paulo 	int olbc; /* Overlapping Legacy BSS Condition */
507e28a4053SRui Paulo 
508e28a4053SRui Paulo 	/* Number of HT associated stations that do not support greenfield */
509e28a4053SRui Paulo 	int num_sta_ht_no_gf;
510e28a4053SRui Paulo 
511e28a4053SRui Paulo 	/* Number of associated non-HT stations */
512e28a4053SRui Paulo 	int num_sta_no_ht;
513e28a4053SRui Paulo 
514e28a4053SRui Paulo 	/* Number of HT associated stations 20 MHz */
515e28a4053SRui Paulo 	int num_sta_ht_20mhz;
516e28a4053SRui Paulo 
5175b9c547cSRui Paulo 	/* Number of HT40 intolerant stations */
5185b9c547cSRui Paulo 	int num_sta_ht40_intolerant;
5195b9c547cSRui Paulo 
520e28a4053SRui Paulo 	/* Overlapping BSS information */
521e28a4053SRui Paulo 	int olbc_ht;
522e28a4053SRui Paulo 
523e28a4053SRui Paulo 	u16 ht_op_mode;
5245b9c547cSRui Paulo 
5255b9c547cSRui Paulo 	/* surveying helpers */
5265b9c547cSRui Paulo 
5275b9c547cSRui Paulo 	/* number of channels surveyed */
5285b9c547cSRui Paulo 	unsigned int chans_surveyed;
5295b9c547cSRui Paulo 
5305b9c547cSRui Paulo 	/* lowest observed noise floor in dBm */
5315b9c547cSRui Paulo 	s8 lowest_nf;
5325b9c547cSRui Paulo 
5335b9c547cSRui Paulo 	/* channel utilization calculation */
5345b9c547cSRui Paulo 	u64 last_channel_time;
5355b9c547cSRui Paulo 	u64 last_channel_time_busy;
5365b9c547cSRui Paulo 	u8 channel_utilization;
5375b9c547cSRui Paulo 
53885732ac8SCy Schubert 	unsigned int chan_util_samples_sum;
53985732ac8SCy Schubert 	unsigned int chan_util_num_sample_periods;
54085732ac8SCy Schubert 	unsigned int chan_util_average;
54185732ac8SCy Schubert 
542780fb4a2SCy Schubert 	/* eCSA IE will be added only if operating class is specified */
543780fb4a2SCy Schubert 	u8 cs_oper_class;
544780fb4a2SCy Schubert 
5455b9c547cSRui Paulo 	unsigned int dfs_cac_ms;
5465b9c547cSRui Paulo 	struct os_reltime dfs_cac_start;
5475b9c547cSRui Paulo 
5485b9c547cSRui Paulo 	/* Latched with the actual secondary channel information and will be
5495b9c547cSRui Paulo 	 * used while juggling between HT20 and HT40 modes. */
5505b9c547cSRui Paulo 	int secondary_ch;
5515b9c547cSRui Paulo 
5525b9c547cSRui Paulo #ifdef CONFIG_ACS
5535b9c547cSRui Paulo 	unsigned int acs_num_completed_scans;
5545b9c547cSRui Paulo #endif /* CONFIG_ACS */
5555b9c547cSRui Paulo 
556e28a4053SRui Paulo 	void (*scan_cb)(struct hostapd_iface *iface);
5575b9c547cSRui Paulo 	int num_ht40_scan_tries;
558325151a3SRui Paulo 
559325151a3SRui Paulo 	struct dl_list sta_seen; /* struct hostapd_sta_info */
560325151a3SRui Paulo 	unsigned int num_sta_seen;
56185732ac8SCy Schubert 
56285732ac8SCy Schubert 	u8 dfs_domain;
563*206b73d0SCy Schubert #ifdef CONFIG_AIRTIME_POLICY
564*206b73d0SCy Schubert 	unsigned int airtime_quantum;
565*206b73d0SCy Schubert #endif /* CONFIG_AIRTIME_POLICY */
566*206b73d0SCy Schubert 
567*206b73d0SCy Schubert 	/* Previous WMM element information */
568*206b73d0SCy Schubert 	struct hostapd_wmm_ac_params prev_wmm[WMM_AC_NUM];
569e28a4053SRui Paulo };
570e28a4053SRui Paulo 
571e28a4053SRui Paulo /* hostapd.c */
572f05cddf9SRui Paulo int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
573f05cddf9SRui Paulo 			       int (*cb)(struct hostapd_iface *iface,
574f05cddf9SRui Paulo 					 void *ctx), void *ctx);
575e28a4053SRui Paulo int hostapd_reload_config(struct hostapd_iface *iface);
57685732ac8SCy Schubert void hostapd_reconfig_encryption(struct hostapd_data *hapd);
577e28a4053SRui Paulo struct hostapd_data *
578e28a4053SRui Paulo hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
579e28a4053SRui Paulo 		       struct hostapd_config *conf,
580e28a4053SRui Paulo 		       struct hostapd_bss_config *bss);
581e28a4053SRui Paulo int hostapd_setup_interface(struct hostapd_iface *iface);
582e28a4053SRui Paulo int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
583e28a4053SRui Paulo void hostapd_interface_deinit(struct hostapd_iface *iface);
584e28a4053SRui Paulo void hostapd_interface_free(struct hostapd_iface *iface);
585780fb4a2SCy Schubert struct hostapd_iface * hostapd_alloc_iface(void);
5865b9c547cSRui Paulo struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
5875b9c547cSRui Paulo 				    const char *config_file);
5885b9c547cSRui Paulo struct hostapd_iface *
5895b9c547cSRui Paulo hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
5905b9c547cSRui Paulo 			   const char *config_fname, int debug);
591e28a4053SRui Paulo void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
592e28a4053SRui Paulo 			   int reassoc);
593f05cddf9SRui Paulo void hostapd_interface_deinit_free(struct hostapd_iface *iface);
594f05cddf9SRui Paulo int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
595f05cddf9SRui Paulo int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
596f05cddf9SRui Paulo int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
597f05cddf9SRui Paulo int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
598f05cddf9SRui Paulo int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
5995b9c547cSRui Paulo void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
6005b9c547cSRui Paulo void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
6015b9c547cSRui Paulo const char * hostapd_state_text(enum hostapd_iface_state s);
602780fb4a2SCy Schubert int hostapd_csa_in_progress(struct hostapd_iface *iface);
60385732ac8SCy Schubert void hostapd_chan_switch_vht_config(struct hostapd_data *hapd, int vht_enabled);
6045b9c547cSRui Paulo int hostapd_switch_channel(struct hostapd_data *hapd,
6055b9c547cSRui Paulo 			   struct csa_settings *settings);
6065b9c547cSRui Paulo void
6075b9c547cSRui Paulo hostapd_switch_channel_fallback(struct hostapd_iface *iface,
6085b9c547cSRui Paulo 				const struct hostapd_freq_params *freq_params);
6095b9c547cSRui Paulo void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
610325151a3SRui Paulo void hostapd_periodic_iface(struct hostapd_iface *iface);
61185732ac8SCy Schubert int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
612e28a4053SRui Paulo 
613e28a4053SRui Paulo /* utils.c */
614e28a4053SRui Paulo int hostapd_register_probereq_cb(struct hostapd_data *hapd,
615e28a4053SRui Paulo 				 int (*cb)(void *ctx, const u8 *sa,
616f05cddf9SRui Paulo 					   const u8 *da, const u8 *bssid,
617f05cddf9SRui Paulo 					   const u8 *ie, size_t ie_len,
618f05cddf9SRui Paulo 					   int ssi_signal),
619e28a4053SRui Paulo 				 void *ctx);
620e28a4053SRui Paulo void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
621e28a4053SRui Paulo 
622e28a4053SRui Paulo /* drv_callbacks.c (TODO: move to somewhere else?) */
62385732ac8SCy Schubert void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd,
62485732ac8SCy Schubert 				      struct sta_info *sta);
625e28a4053SRui Paulo int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
626f05cddf9SRui Paulo 			const u8 *ie, size_t ielen, int reassoc);
627e28a4053SRui Paulo void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
628f05cddf9SRui Paulo void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
6295b9c547cSRui Paulo void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
6305b9c547cSRui Paulo 					 const u8 *addr, int reason_code);
631f05cddf9SRui Paulo int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
632f05cddf9SRui Paulo 			 const u8 *bssid, const u8 *ie, size_t ie_len,
633f05cddf9SRui Paulo 			 int ssi_signal);
634f05cddf9SRui Paulo void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
635*206b73d0SCy Schubert 			     int offset, int width, int cf1, int cf2,
636*206b73d0SCy Schubert 			     int finished);
637780fb4a2SCy Schubert struct survey_results;
638780fb4a2SCy Schubert void hostapd_event_get_survey(struct hostapd_iface *iface,
639780fb4a2SCy Schubert 			      struct survey_results *survey_results);
640780fb4a2SCy Schubert void hostapd_acs_channel_selected(struct hostapd_data *hapd,
641780fb4a2SCy Schubert 				  struct acs_selected_channels *acs_res);
642f05cddf9SRui Paulo 
643f05cddf9SRui Paulo const struct hostapd_eap_user *
644f05cddf9SRui Paulo hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
645f05cddf9SRui Paulo 		     size_t identity_len, int phase2);
646e28a4053SRui Paulo 
647325151a3SRui Paulo struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces,
648325151a3SRui Paulo 					const char *ifname);
64985732ac8SCy Schubert void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr,
65085732ac8SCy Schubert 				      enum smps_mode smps_mode,
65185732ac8SCy Schubert 				      enum chan_width chan_width, u8 rx_nss);
652325151a3SRui Paulo 
653325151a3SRui Paulo #ifdef CONFIG_FST
654325151a3SRui Paulo void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
655325151a3SRui Paulo 				struct fst_wpa_obj *iface_obj);
656325151a3SRui Paulo #endif /* CONFIG_FST */
657325151a3SRui Paulo 
658e28a4053SRui Paulo #endif /* HOSTAPD_H */
659