1 /*
2  * hostapd / Initialization and configuration
3  * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef HOSTAPD_H
10 #define HOSTAPD_H
11 
12 #ifdef CONFIG_SQLITE
13 #include <sqlite3.h>
14 #endif /* CONFIG_SQLITE */
15 
16 #include "common/defs.h"
17 #include "common/dpp.h"
18 #include "utils/list.h"
19 #include "ap_config.h"
20 #include "drivers/driver.h"
21 
22 #define OCE_STA_CFON_ENABLED(hapd) \
23 	((hapd->conf->oce & OCE_STA_CFON) && \
24 	 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_STA_CFON))
25 #define OCE_AP_ENABLED(hapd) \
26 	((hapd->conf->oce & OCE_AP) && \
27 	 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_AP))
28 
29 struct wpa_ctrl_dst;
30 struct radius_server_data;
31 struct upnp_wps_device_sm;
32 struct hostapd_data;
33 struct sta_info;
34 struct ieee80211_ht_capabilities;
35 struct full_dynamic_vlan;
36 enum wps_event;
37 union wps_event_data;
38 #ifdef CONFIG_MESH
39 struct mesh_conf;
40 #endif /* CONFIG_MESH */
41 
42 #ifdef CONFIG_CTRL_IFACE_UDP
43 #define CTRL_IFACE_COOKIE_LEN 8
44 #endif /* CONFIG_CTRL_IFACE_UDP */
45 
46 struct hostapd_iface;
47 struct hostapd_mld;
48 
49 struct hapd_interfaces {
50 	int (*reload_config)(struct hostapd_iface *iface);
51 	struct hostapd_config * (*config_read_cb)(const char *config_fname);
52 	int (*ctrl_iface_init)(struct hostapd_data *hapd);
53 	void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
54 	int (*for_each_interface)(struct hapd_interfaces *interfaces,
55 				  int (*cb)(struct hostapd_iface *iface,
56 					    void *ctx), void *ctx);
57 	int (*driver_init)(struct hostapd_iface *iface);
58 
59 	size_t count;
60 	int global_ctrl_sock;
61 	struct dl_list global_ctrl_dst;
62 	char *global_iface_path;
63 	char *global_iface_name;
64 #ifndef CONFIG_NATIVE_WINDOWS
65 	gid_t ctrl_iface_group;
66 #endif /* CONFIG_NATIVE_WINDOWS */
67 	struct hostapd_iface **iface;
68 
69 	size_t terminate_on_error;
70 #ifndef CONFIG_NO_VLAN
71 	struct dynamic_iface *vlan_priv;
72 #endif /* CONFIG_NO_VLAN */
73 #ifdef CONFIG_ETH_P_OUI
74 	struct dl_list eth_p_oui; /* OUI Extended EtherType handlers */
75 #endif /* CONFIG_ETH_P_OUI */
76 	int eloop_initialized;
77 
78 #ifdef CONFIG_DPP
79 	struct dpp_global *dpp;
80 #ifdef CONFIG_DPP3
81 	struct os_reltime dpp_pb_time;
82 	struct os_reltime dpp_pb_announce_time;
83 	struct dpp_pb_info dpp_pb[DPP_PB_INFO_COUNT];
84 	struct dpp_bootstrap_info *dpp_pb_bi;
85 	u8 dpp_pb_c_nonce[DPP_MAX_NONCE_LEN];
86 	u8 dpp_pb_resp_hash[SHA256_MAC_LEN];
87 	struct os_reltime dpp_pb_last_resp;
88 	bool dpp_pb_result_indicated;
89 	char *dpp_pb_cmd;
90 #endif /* CONFIG_DPP3 */
91 #endif /* CONFIG_DPP */
92 
93 #ifdef CONFIG_CTRL_IFACE_UDP
94        unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
95 #endif /* CONFIG_CTRL_IFACE_UDP */
96 
97 #ifdef CONFIG_IEEE80211BE
98 	struct hostapd_mld **mld;
99 	size_t mld_count;
100 #endif /* CONFIG_IEEE80211BE */
101 };
102 
103 enum hostapd_chan_status {
104 	HOSTAPD_CHAN_VALID = 0, /* channel is ready */
105 	HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */
106 	HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */
107 	HOSTAPD_CHAN_INVALID_NO_IR = 3, /* channel invalid due to AFC NO IR */
108 };
109 
110 struct hostapd_probereq_cb {
111 	int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
112 		  const u8 *ie, size_t ie_len, int ssi_signal);
113 	void *ctx;
114 };
115 
116 #define HOSTAPD_RATE_BASIC 0x00000001
117 
118 struct hostapd_rate_data {
119 	int rate; /* rate in 100 kbps */
120 	int flags; /* HOSTAPD_RATE_ flags */
121 };
122 
123 struct hostapd_frame_info {
124 	unsigned int freq;
125 	u32 channel;
126 	u32 datarate;
127 	int ssi_signal; /* dBm */
128 };
129 
130 enum wps_status {
131 	WPS_STATUS_SUCCESS = 1,
132 	WPS_STATUS_FAILURE
133 };
134 
135 enum pbc_status {
136 	WPS_PBC_STATUS_DISABLE,
137 	WPS_PBC_STATUS_ACTIVE,
138 	WPS_PBC_STATUS_TIMEOUT,
139 	WPS_PBC_STATUS_OVERLAP
140 };
141 
142 struct wps_stat {
143 	enum wps_status status;
144 	enum wps_error_indication failure_reason;
145 	enum pbc_status pbc_status;
146 	u8 peer_addr[ETH_ALEN];
147 };
148 
149 struct hostapd_neighbor_entry {
150 	struct dl_list list;
151 	u8 bssid[ETH_ALEN];
152 	struct wpa_ssid_value ssid;
153 	struct wpabuf *nr;
154 	struct wpabuf *lci;
155 	struct wpabuf *civic;
156 	/* LCI update time */
157 	struct os_time lci_date;
158 	int stationary;
159 	u32 short_ssid;
160 	u8 bss_parameters;
161 };
162 
163 struct hostapd_sae_commit_queue {
164 	struct dl_list list;
165 	int rssi;
166 	size_t len;
167 	u8 msg[];
168 };
169 
170 /**
171  * struct hostapd_data - hostapd per-BSS data structure
172  */
173 struct hostapd_data {
174 #if defined(__ZEPHYR__) && defined(HOSTAPD)
175 	/** Zephyr has coexistence of hostapd and wpa_supplicant.
176 	 * To verify if ctx is hostapd or wpa_supplicant in wpa_msg,
177 	 * this should be the first parameter
178 	 */
179 	int is_hostapd;
180 #endif
181 	struct hostapd_iface *iface;
182 	struct hostapd_config *iconf;
183 	struct hostapd_bss_config *conf;
184 	int interface_added; /* virtual interface added for this BSS */
185 	unsigned int started:1;
186 	unsigned int disabled:1;
187 	unsigned int reenable_beacon:1;
188 
189 	u8 own_addr[ETH_ALEN];
190 
191 	int num_sta; /* number of entries in sta_list */
192 	struct sta_info *sta_list; /* STA info list head */
193 #define STA_HASH_SIZE 256
194 #define STA_HASH(sta) (sta[5])
195 	struct sta_info *sta_hash[STA_HASH_SIZE];
196 
197 	/*
198 	 * Bitfield for indicating which AIDs are allocated. Only AID values
199 	 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
200 	 * 1.
201 	 */
202 #define AID_WORDS ((2008 + 31) / 32)
203 	u32 sta_aid[AID_WORDS];
204 
205 	const struct wpa_driver_ops *driver;
206 	void *drv_priv;
207 
208 	void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
209 				 struct sta_info *sta, int reassoc);
210 
211 	void *msg_ctx; /* ctx for wpa_msg() calls */
212 	void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
213 
214 	struct radius_client_data *radius;
215 	u64 acct_session_id;
216 	struct radius_das_data *radius_das;
217 
218 	struct hostapd_cached_radius_acl *acl_cache;
219 	struct hostapd_acl_query_data *acl_queries;
220 
221 	struct wpa_authenticator *wpa_auth;
222 	struct eapol_authenticator *eapol_auth;
223 	struct eap_config *eap_cfg;
224 
225 	struct rsn_preauth_interface *preauth_iface;
226 	struct os_reltime michael_mic_failure;
227 	int michael_mic_failures;
228 	int tkip_countermeasures;
229 
230 	int ctrl_sock;
231 	struct dl_list ctrl_dst;
232 
233 	void *ssl_ctx;
234 	void *eap_sim_db_priv;
235 	struct crypto_rsa_key *imsi_privacy_key;
236 	struct radius_server_data *radius_srv;
237 	struct dl_list erp_keys; /* struct eap_server_erp_key */
238 
239 	int parameter_set_count;
240 
241 	/* Time Advertisement */
242 	u8 time_update_counter;
243 	struct wpabuf *time_adv;
244 
245 #ifdef CONFIG_FULL_DYNAMIC_VLAN
246 	struct full_dynamic_vlan *full_dynamic_vlan;
247 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
248 
249 	struct l2_packet_data *l2;
250 
251 #ifdef CONFIG_IEEE80211R_AP
252 	struct dl_list l2_queue;
253 	struct dl_list l2_oui_queue;
254 	struct eth_p_oui_ctx *oui_pull;
255 	struct eth_p_oui_ctx *oui_resp;
256 	struct eth_p_oui_ctx *oui_push;
257 	struct eth_p_oui_ctx *oui_sreq;
258 	struct eth_p_oui_ctx *oui_sresp;
259 #endif /* CONFIG_IEEE80211R_AP */
260 
261 	struct wps_context *wps;
262 
263 	int beacon_set_done;
264 	struct wpabuf *wps_beacon_ie;
265 	struct wpabuf *wps_probe_resp_ie;
266 #ifdef CONFIG_WPS
267 	unsigned int ap_pin_failures;
268 	unsigned int ap_pin_failures_consecutive;
269 	struct upnp_wps_device_sm *wps_upnp;
270 	unsigned int ap_pin_lockout_time;
271 
272 	struct wps_stat wps_stats;
273 #endif /* CONFIG_WPS */
274 
275 #ifdef CONFIG_MACSEC
276 	struct ieee802_1x_kay *kay;
277 #endif /* CONFIG_MACSEC */
278 
279 	struct hostapd_probereq_cb *probereq_cb;
280 	size_t num_probereq_cb;
281 
282 	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
283 				 int freq);
284 	void *public_action_cb_ctx;
285 	void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
286 				  int freq);
287 	void *public_action_cb2_ctx;
288 
289 	int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
290 				int freq);
291 	void *vendor_action_cb_ctx;
292 
293 	void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
294 				   const u8 *uuid_e);
295 	void *wps_reg_success_cb_ctx;
296 
297 	void (*wps_event_cb)(void *ctx, enum wps_event event,
298 			     union wps_event_data *data);
299 	void *wps_event_cb_ctx;
300 
301 	void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
302 				  int authorized, const u8 *p2p_dev_addr,
303 				  const u8 *ip);
304 	void *sta_authorized_cb_ctx;
305 
306 	void (*setup_complete_cb)(void *ctx);
307 	void *setup_complete_cb_ctx;
308 
309 	void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
310 			   const u8 *p2p_dev_addr, const u8 *psk,
311 			   size_t psk_len);
312 	void *new_psk_cb_ctx;
313 
314 	/* channel switch parameters */
315 	struct hostapd_freq_params cs_freq_params;
316 	u8 cs_count;
317 	int cs_block_tx;
318 	unsigned int cs_c_off_beacon;
319 	unsigned int cs_c_off_proberesp;
320 	int csa_in_progress;
321 	unsigned int cs_c_off_ecsa_beacon;
322 	unsigned int cs_c_off_ecsa_proberesp;
323 
324 #ifdef CONFIG_IEEE80211AX
325 	bool cca_in_progress;
326 	u8 cca_count;
327 	u8 cca_color;
328 	unsigned int cca_c_off_beacon;
329 	unsigned int cca_c_off_proberesp;
330 	struct os_reltime first_color_collision;
331 	struct os_reltime last_color_collision;
332 	u64 color_collision_bitmap;
333 #endif /* CONFIG_IEEE80211AX */
334 
335 #ifdef CONFIG_P2P
336 	struct p2p_data *p2p;
337 	struct p2p_group *p2p_group;
338 	struct wpabuf *p2p_beacon_ie;
339 	struct wpabuf *p2p_probe_resp_ie;
340 
341 	/* Number of non-P2P association stations */
342 	int num_sta_no_p2p;
343 
344 	/* Periodic NoA (used only when no non-P2P clients in the group) */
345 	int noa_enabled;
346 	int noa_start;
347 	int noa_duration;
348 #endif /* CONFIG_P2P */
349 #ifdef CONFIG_PROXYARP
350 	struct l2_packet_data *sock_dhcp;
351 	struct l2_packet_data *sock_ndisc;
352 	bool x_snoop_initialized;
353 #endif /* CONFIG_PROXYARP */
354 #ifdef CONFIG_MESH
355 	int num_plinks;
356 	int max_plinks;
357 	void (*mesh_sta_free_cb)(struct hostapd_data *hapd,
358 				 struct sta_info *sta);
359 	struct wpabuf *mesh_pending_auth;
360 	struct os_reltime mesh_pending_auth_time;
361 	u8 mesh_required_peer[ETH_ALEN];
362 #endif /* CONFIG_MESH */
363 
364 #ifdef CONFIG_SQLITE
365 	struct hostapd_eap_user tmp_eap_user;
366 #endif /* CONFIG_SQLITE */
367 
368 #ifdef CONFIG_SAE
369 
370 #define COMEBACK_KEY_SIZE 8
371 #define COMEBACK_PENDING_IDX_SIZE 256
372 
373 	/** Key used for generating SAE anti-clogging tokens */
374 	u8 comeback_key[COMEBACK_KEY_SIZE];
375 	struct os_reltime last_comeback_key_update;
376 	u16 comeback_idx;
377 	u16 comeback_pending_idx[COMEBACK_PENDING_IDX_SIZE];
378 	int dot11RSNASAERetransPeriod; /* msec */
379 	struct dl_list sae_commit_queue; /* struct hostapd_sae_commit_queue */
380 #endif /* CONFIG_SAE */
381 
382 #ifdef CONFIG_TESTING_OPTIONS
383 	unsigned int ext_mgmt_frame_handling:1;
384 	unsigned int ext_eapol_frame_io:1;
385 
386 	struct l2_packet_data *l2_test;
387 
388 	enum wpa_alg last_gtk_alg;
389 	int last_gtk_key_idx;
390 	u8 last_gtk[WPA_GTK_MAX_LEN];
391 	size_t last_gtk_len;
392 
393 	enum wpa_alg last_igtk_alg;
394 	int last_igtk_key_idx;
395 	u8 last_igtk[WPA_IGTK_MAX_LEN];
396 	size_t last_igtk_len;
397 
398 	enum wpa_alg last_bigtk_alg;
399 	int last_bigtk_key_idx;
400 	u8 last_bigtk[WPA_BIGTK_MAX_LEN];
401 	size_t last_bigtk_len;
402 
403 	bool force_backlog_bytes;
404 #endif /* CONFIG_TESTING_OPTIONS */
405 
406 #ifdef CONFIG_MBO
407 	unsigned int mbo_assoc_disallow;
408 #endif /* CONFIG_MBO */
409 
410 	struct dl_list nr_db;
411 
412 	u8 beacon_req_token;
413 	u8 lci_req_token;
414 	u8 range_req_token;
415 	u8 link_measurement_req_token;
416 	unsigned int lci_req_active:1;
417 	unsigned int range_req_active:1;
418 	unsigned int link_mesr_req_active:1;
419 
420 	int dhcp_sock; /* UDP socket used with the DHCP server */
421 
422 	struct ptksa_cache *ptksa;
423 
424 #ifdef CONFIG_DPP
425 	int dpp_init_done;
426 	struct dpp_authentication *dpp_auth;
427 	u8 dpp_allowed_roles;
428 	int dpp_qr_mutual;
429 	int dpp_auth_ok_on_ack;
430 	int dpp_in_response_listen;
431 	struct gas_query_ap *gas;
432 	struct dpp_pkex *dpp_pkex;
433 	struct dpp_bootstrap_info *dpp_pkex_bi;
434 	char *dpp_pkex_code;
435 	size_t dpp_pkex_code_len;
436 	char *dpp_pkex_identifier;
437 	enum dpp_pkex_ver dpp_pkex_ver;
438 	char *dpp_pkex_auth_cmd;
439 	char *dpp_configurator_params;
440 	struct os_reltime dpp_last_init;
441 	struct os_reltime dpp_init_iter_start;
442 	unsigned int dpp_init_max_tries;
443 	unsigned int dpp_init_retry_time;
444 	unsigned int dpp_resp_wait_time;
445 	unsigned int dpp_resp_max_tries;
446 	unsigned int dpp_resp_retry_time;
447 #ifdef CONFIG_DPP2
448 	struct wpabuf *dpp_presence_announcement;
449 	struct dpp_bootstrap_info *dpp_chirp_bi;
450 	int dpp_chirp_freq;
451 	int *dpp_chirp_freqs;
452 	int dpp_chirp_iter;
453 	int dpp_chirp_round;
454 	int dpp_chirp_scan_done;
455 	int dpp_chirp_listen;
456 	struct os_reltime dpp_relay_last_needs_ctrl;
457 #endif /* CONFIG_DPP2 */
458 #ifdef CONFIG_TESTING_OPTIONS
459 	char *dpp_config_obj_override;
460 	char *dpp_discovery_override;
461 	char *dpp_groups_override;
462 	unsigned int dpp_ignore_netaccesskey_mismatch:1;
463 #endif /* CONFIG_TESTING_OPTIONS */
464 #endif /* CONFIG_DPP */
465 
466 #ifdef CONFIG_AIRTIME_POLICY
467 	unsigned int num_backlogged_sta;
468 	unsigned int airtime_weight;
469 #endif /* CONFIG_AIRTIME_POLICY */
470 
471 	u8 last_1x_eapol_key_replay_counter[8];
472 
473 #ifdef CONFIG_SQLITE
474 	sqlite3 *rad_attr_db;
475 #endif /* CONFIG_SQLITE */
476 
477 #ifdef CONFIG_CTRL_IFACE_UDP
478        unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN];
479 #endif /* CONFIG_CTRL_IFACE_UDP */
480 
481 #ifdef CONFIG_IEEE80211BE
482 	u8 eht_mld_bss_param_change;
483 	struct hostapd_mld *mld;
484 	struct dl_list link;
485 	u8 mld_link_id;
486 #ifdef CONFIG_TESTING_OPTIONS
487 	u8 eht_mld_link_removal_count;
488 #endif /* CONFIG_TESTING_OPTIONS */
489 #endif /* CONFIG_IEEE80211BE */
490 
491 #ifdef CONFIG_NAN_USD
492 	struct nan_de *nan_de;
493 #endif /* CONFIG_NAN_USD */
494 
495 	u64 scan_cookie; /* Scan instance identifier for the ongoing HT40 scan
496 			  */
497 };
498 
499 
500 struct hostapd_sta_info {
501 	struct dl_list list;
502 	u8 addr[ETH_ALEN];
503 	struct os_reltime last_seen;
504 	int ssi_signal;
505 #ifdef CONFIG_TAXONOMY
506 	struct wpabuf *probe_ie_taxonomy;
507 #endif /* CONFIG_TAXONOMY */
508 };
509 
510 #ifdef CONFIG_IEEE80211BE
511 /**
512  * struct hostapd_mld - hostapd per-mld data structure
513  */
514 struct hostapd_mld {
515 	char name[IFNAMSIZ + 1];
516 	u8 mld_addr[ETH_ALEN];
517 	u8 next_link_id;
518 	u8 num_links;
519 	/* Number of hostapd_data (hapd) referencing this. num_links cannot be
520 	 * used since num_links can go to 0 even when a BSS is disabled and
521 	 * when it is re-enabled, the MLD should exist and hence it cannot be
522 	 * freed when num_links is 0.
523 	 */
524 	u8 refcount;
525 
526 	struct hostapd_data *fbss;
527 	struct dl_list links; /* List head of all affiliated links */
528 };
529 
530 #define HOSTAPD_MLD_MAX_REF_COUNT      0xFF
531 #endif /* CONFIG_IEEE80211BE */
532 
533 /**
534  * struct hostapd_iface - hostapd per-interface data structure
535  */
536 struct hostapd_iface {
537 	struct hapd_interfaces *interfaces;
538 	void *owner;
539 	char *config_fname;
540 	struct hostapd_config *conf;
541 	char phy[16]; /* Name of the PHY (radio) */
542 
543 	enum hostapd_iface_state {
544 		HAPD_IFACE_UNINITIALIZED,
545 		HAPD_IFACE_DISABLED,
546 		HAPD_IFACE_COUNTRY_UPDATE,
547 		HAPD_IFACE_ACS,
548 		HAPD_IFACE_HT_SCAN,
549 		HAPD_IFACE_DFS,
550 		HAPD_IFACE_NO_IR,
551 		HAPD_IFACE_ENABLED
552 	} state;
553 
554 #ifdef CONFIG_MESH
555 	struct mesh_conf *mconf;
556 #endif /* CONFIG_MESH */
557 
558 	size_t num_bss;
559 	struct hostapd_data **bss;
560 
561 	unsigned int wait_channel_update:1;
562 	unsigned int cac_started:1;
563 #ifdef CONFIG_FST
564 	struct fst_iface *fst;
565 	const struct wpabuf *fst_ies;
566 #endif /* CONFIG_FST */
567 
568 	/*
569 	 * When set, indicates that the driver will handle the AP
570 	 * teardown: delete global keys, station keys, and stations.
571 	 */
572 	unsigned int driver_ap_teardown:1;
573 
574 	/*
575 	 * When set, indicates that this interface is part of list of
576 	 * interfaces that need to be started together (synchronously).
577 	 */
578 	unsigned int need_to_start_in_sync:1;
579 
580 	/* Ready to start but waiting for other interfaces to become ready. */
581 	unsigned int ready_to_start_in_sync:1;
582 
583 	int num_ap; /* number of entries in ap_list */
584 	struct ap_info *ap_list; /* AP info list head */
585 	struct ap_info *ap_hash[STA_HASH_SIZE];
586 
587 	u64 drv_flags;
588 	u64 drv_flags2;
589 	unsigned int drv_rrm_flags;
590 
591 	/*
592 	 * A bitmap of supported protocols for probe response offload. See
593 	 * struct wpa_driver_capa in driver.h
594 	 */
595 	unsigned int probe_resp_offloads;
596 
597 	/* extended capabilities supported by the driver */
598 	const u8 *extended_capa, *extended_capa_mask;
599 	unsigned int extended_capa_len;
600 
601 	u16 mld_eml_capa, mld_mld_capa;
602 
603 	unsigned int drv_max_acl_mac_addrs;
604 
605 	struct hostapd_hw_modes *hw_features;
606 	int num_hw_features;
607 	struct hostapd_hw_modes *current_mode;
608 	/* Rates that are currently used (i.e., filtered copy of
609 	 * current_mode->channels */
610 	int num_rates;
611 	struct hostapd_rate_data *current_rates;
612 	int *basic_rates;
613 	int freq;
614 
615 	bool radar_detected;
616 
617 	/* Background radar configuration */
618 	struct {
619 		int channel;
620 		int secondary_channel;
621 		int freq;
622 		int centr_freq_seg0_idx;
623 		int centr_freq_seg1_idx;
624 		/* Main chain is on temporary channel during
625 		 * CAC detection on radar offchain.
626 		 */
627 		unsigned int temp_ch:1;
628 		/* CAC started on radar offchain */
629 		unsigned int cac_started:1;
630 	} radar_background;
631 
632 	u16 hw_flags;
633 
634 	/* Number of associated Non-ERP stations (i.e., stations using 802.11b
635 	 * in 802.11g BSS) */
636 	int num_sta_non_erp;
637 
638 	/* Number of associated stations that do not support Short Slot Time */
639 	int num_sta_no_short_slot_time;
640 
641 	/* Number of associated stations that do not support Short Preamble */
642 	int num_sta_no_short_preamble;
643 
644 	int olbc; /* Overlapping Legacy BSS Condition */
645 
646 	/* Number of HT associated stations that do not support greenfield */
647 	int num_sta_ht_no_gf;
648 
649 	/* Number of associated non-HT stations */
650 	int num_sta_no_ht;
651 
652 	/* Number of HT associated stations 20 MHz */
653 	int num_sta_ht_20mhz;
654 
655 	/* Number of HT40 intolerant stations */
656 	int num_sta_ht40_intolerant;
657 
658 	/* Overlapping BSS information */
659 	int olbc_ht;
660 
661 	u16 ht_op_mode;
662 
663 	/* surveying helpers */
664 
665 	/* number of channels surveyed */
666 	unsigned int chans_surveyed;
667 
668 	/* lowest observed noise floor in dBm */
669 	s8 lowest_nf;
670 
671 	/* channel utilization calculation */
672 	u64 last_channel_time;
673 	u64 last_channel_time_busy;
674 	u8 channel_utilization;
675 
676 	unsigned int chan_util_samples_sum;
677 	unsigned int chan_util_num_sample_periods;
678 	unsigned int chan_util_average;
679 
680 	/* eCSA IE will be added only if operating class is specified */
681 	u8 cs_oper_class;
682 
683 	unsigned int dfs_cac_ms;
684 	struct os_reltime dfs_cac_start;
685 
686 	/* Latched with the actual secondary channel information and will be
687 	 * used while juggling between HT20 and HT40 modes. */
688 	int secondary_ch;
689 
690 #ifdef CONFIG_ACS
691 	unsigned int acs_num_completed_scans;
692 	unsigned int acs_num_retries;
693 #endif /* CONFIG_ACS */
694 
695 	void (*scan_cb)(struct hostapd_iface *iface);
696 	int num_ht40_scan_tries;
697 
698 	struct dl_list sta_seen; /* struct hostapd_sta_info */
699 	unsigned int num_sta_seen;
700 
701 	u8 dfs_domain;
702 #ifdef CONFIG_AIRTIME_POLICY
703 	unsigned int airtime_quantum;
704 #endif /* CONFIG_AIRTIME_POLICY */
705 
706 	/* Previous WMM element information */
707 	struct hostapd_wmm_ac_params prev_wmm[WMM_AC_NUM];
708 
709 	/* Maximum number of interfaces supported for MBSSID advertisement */
710 	unsigned int mbssid_max_interfaces;
711 	/* Maximum profile periodicity for enhanced MBSSID advertisement */
712 	unsigned int ema_max_periodicity;
713 
714 	int (*enable_iface_cb)(struct hostapd_iface *iface);
715 	int (*disable_iface_cb)(struct hostapd_iface *iface);
716 
717 	/* Configured freq of interface is NO_IR */
718 	bool is_no_ir;
719 
720 	bool is_ch_switch_dfs; /* Channel switch from ACS to DFS */
721 };
722 
723 /* hostapd.c */
724 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
725 			       int (*cb)(struct hostapd_iface *iface,
726 					 void *ctx), void *ctx);
727 int hostapd_reload_config(struct hostapd_iface *iface);
728 void hostapd_reconfig_encryption(struct hostapd_data *hapd);
729 struct hostapd_data *
730 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
731 		       struct hostapd_config *conf,
732 		       struct hostapd_bss_config *bss);
733 int hostapd_setup_interface(struct hostapd_iface *iface);
734 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
735 void hostapd_interface_deinit(struct hostapd_iface *iface);
736 void hostapd_interface_free(struct hostapd_iface *iface);
737 struct hostapd_iface * hostapd_alloc_iface(void);
738 struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
739 				    const char *config_file);
740 struct hostapd_iface *
741 hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
742 			   const char *config_fname, int debug);
743 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
744 			   int reassoc);
745 void hostapd_interface_deinit_free(struct hostapd_iface *iface);
746 int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
747 int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
748 int hostapd_reload_bss_only(struct hostapd_data *bss);
749 int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
750 void hostapd_bss_deinit_no_free(struct hostapd_data *hapd);
751 void hostapd_free_hapd_data(struct hostapd_data *hapd);
752 void hostapd_cleanup_iface_partial(struct hostapd_iface *iface);
753 int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
754 int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
755 void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
756 void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
757 const char * hostapd_state_text(enum hostapd_iface_state s);
758 int hostapd_csa_in_progress(struct hostapd_iface *iface);
759 void hostapd_chan_switch_config(struct hostapd_data *hapd,
760 				struct hostapd_freq_params *freq_params);
761 int hostapd_switch_channel(struct hostapd_data *hapd,
762 			   struct csa_settings *settings);
763 void
764 hostapd_switch_channel_fallback(struct hostapd_iface *iface,
765 				const struct hostapd_freq_params *freq_params);
766 void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
767 void hostapd_periodic_iface(struct hostapd_iface *iface);
768 int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
769 void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx);
770 
771 void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap);
772 void hostapd_cleanup_cca_params(struct hostapd_data *hapd);
773 
774 /* utils.c */
775 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
776 				 int (*cb)(void *ctx, const u8 *sa,
777 					   const u8 *da, const u8 *bssid,
778 					   const u8 *ie, size_t ie_len,
779 					   int ssi_signal),
780 				 void *ctx);
781 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr,
782 				int mld_assoc_link_id);
783 
784 /* drv_callbacks.c (TODO: move to somewhere else?) */
785 void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd,
786 				      struct sta_info *sta);
787 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
788 			const u8 *req_ie, size_t req_ielen, const u8 *resp_ie,
789 			size_t resp_ielen, const u8 *link_addr, int reassoc);
790 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
791 void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
792 void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
793 					 const u8 *addr, int reason_code);
794 int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
795 			 const u8 *bssid, const u8 *ie, size_t ie_len,
796 			 int ssi_signal);
797 void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
798 			     int offset, int width, int cf1, int cf2,
799 			     u16 punct_bitmap, int finished);
800 struct survey_results;
801 void hostapd_event_get_survey(struct hostapd_iface *iface,
802 			      struct survey_results *survey_results);
803 void hostapd_acs_channel_selected(struct hostapd_data *hapd,
804 				  struct acs_selected_channels *acs_res);
805 
806 const struct hostapd_eap_user *
807 hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
808 		     size_t identity_len, int phase2);
809 
810 struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces,
811 					const char *ifname);
812 void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr,
813 				      enum smps_mode smps_mode,
814 				      enum chan_width chan_width, u8 rx_nss);
815 
816 #ifdef CONFIG_FST
817 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
818 				struct fst_wpa_obj *iface_obj);
819 #endif /* CONFIG_FST */
820 
821 int hostapd_set_acl(struct hostapd_data *hapd);
822 struct hostapd_data * hostapd_mbssid_get_tx_bss(struct hostapd_data *hapd);
823 int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd);
824 struct hostapd_data * hostapd_mld_get_link_bss(struct hostapd_data *hapd,
825 					       u8 link_id);
826 int hostapd_link_remove(struct hostapd_data *hapd, u32 count);
827 bool hostapd_is_ml_partner(struct hostapd_data *hapd1,
828 			   struct hostapd_data *hapd2);
829 u8 hostapd_get_mld_id(struct hostapd_data *hapd);
830 int hostapd_mld_add_link(struct hostapd_data *hapd);
831 int hostapd_mld_remove_link(struct hostapd_data *hapd);
832 struct hostapd_data * hostapd_mld_get_first_bss(struct hostapd_data *hapd);
833 
834 void free_beacon_data(struct beacon_data *beacon);
835 int hostapd_fill_cca_settings(struct hostapd_data *hapd,
836 			      struct cca_settings *settings);
837 
838 #ifdef CONFIG_IEEE80211BE
839 
840 bool hostapd_mld_is_first_bss(struct hostapd_data *hapd);
841 
842 #define for_each_mld_link(partner, self) \
843 	dl_list_for_each(partner, &self->mld->links, struct hostapd_data, link)
844 
845 #else /* CONFIG_IEEE80211BE */
846 
hostapd_mld_is_first_bss(struct hostapd_data * hapd)847 static inline bool hostapd_mld_is_first_bss(struct hostapd_data *hapd)
848 {
849 	return true;
850 }
851 
852 #define for_each_mld_link(partner, self) \
853 	if (false)
854 
855 #endif /* CONFIG_IEEE80211BE */
856 
857 u16 hostapd_get_punct_bitmap(struct hostapd_data *hapd);
858 
859 #endif /* HOSTAPD_H */
860