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