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