b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 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 | #include "ubus.h" |
| 22 | |
| 23 | #define OCE_STA_CFON_ENABLED(hapd) \ |
| 24 | ((hapd->conf->oce & OCE_STA_CFON) && \ |
| 25 | (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_STA_CFON)) |
| 26 | #define OCE_AP_ENABLED(hapd) \ |
| 27 | ((hapd->conf->oce & OCE_AP) && \ |
| 28 | (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_OCE_AP)) |
| 29 | |
| 30 | struct wpa_ctrl_dst; |
| 31 | struct radius_server_data; |
| 32 | struct upnp_wps_device_sm; |
| 33 | struct hostapd_data; |
| 34 | struct sta_info; |
| 35 | struct ieee80211_ht_capabilities; |
| 36 | struct full_dynamic_vlan; |
| 37 | enum wps_event; |
| 38 | union wps_event_data; |
| 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 | |
| 49 | struct hapd_interfaces { |
| 50 | int (*reload_config)(struct hostapd_iface *iface, int reconf); |
| 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 | struct ubus_object ubus; |
| 97 | }; |
| 98 | |
| 99 | enum hostapd_chan_status { |
| 100 | HOSTAPD_CHAN_VALID = 0, /* channel is ready */ |
| 101 | HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */ |
| 102 | HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */ |
| 103 | HOSTAPD_CHAN_INVALID_NO_IR = 3, /* channel invalid due to AFC NO IR */ |
| 104 | }; |
| 105 | |
| 106 | struct hostapd_probereq_cb { |
| 107 | int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid, |
| 108 | const u8 *ie, size_t ie_len, int ssi_signal); |
| 109 | void *ctx; |
| 110 | }; |
| 111 | |
| 112 | #define HOSTAPD_RATE_BASIC 0x00000001 |
| 113 | |
| 114 | struct hostapd_rate_data { |
| 115 | int rate; /* rate in 100 kbps */ |
| 116 | int flags; /* HOSTAPD_RATE_ flags */ |
| 117 | }; |
| 118 | |
| 119 | struct hostapd_frame_info { |
| 120 | unsigned int freq; |
| 121 | u32 channel; |
| 122 | u32 datarate; |
| 123 | int ssi_signal; /* dBm */ |
| 124 | }; |
| 125 | |
| 126 | enum wps_status { |
| 127 | WPS_STATUS_SUCCESS = 1, |
| 128 | WPS_STATUS_FAILURE |
| 129 | }; |
| 130 | |
| 131 | enum pbc_status { |
| 132 | WPS_PBC_STATUS_DISABLE, |
| 133 | WPS_PBC_STATUS_ACTIVE, |
| 134 | WPS_PBC_STATUS_TIMEOUT, |
| 135 | WPS_PBC_STATUS_OVERLAP |
| 136 | }; |
| 137 | |
| 138 | struct wps_stat { |
| 139 | enum wps_status status; |
| 140 | enum wps_error_indication failure_reason; |
| 141 | enum pbc_status pbc_status; |
| 142 | u8 peer_addr[ETH_ALEN]; |
| 143 | }; |
| 144 | |
| 145 | struct hostapd_neighbor_entry { |
| 146 | struct dl_list list; |
| 147 | u8 bssid[ETH_ALEN]; |
| 148 | struct wpa_ssid_value ssid; |
| 149 | struct wpabuf *nr; |
| 150 | struct wpabuf *lci; |
| 151 | struct wpabuf *civic; |
| 152 | /* LCI update time */ |
| 153 | struct os_time lci_date; |
| 154 | int stationary; |
| 155 | u32 short_ssid; |
| 156 | u8 bss_parameters; |
| 157 | }; |
| 158 | |
| 159 | struct hostapd_sae_commit_queue { |
| 160 | struct dl_list list; |
| 161 | int rssi; |
| 162 | size_t len; |
| 163 | u8 msg[]; |
| 164 | }; |
| 165 | |
| 166 | /** |
| 167 | * struct hostapd_openwrt_stats - OpenWrt custom STA/AP statistics |
| 168 | */ |
| 169 | struct hostapd_openwrt_stats { |
| 170 | struct { |
| 171 | u64 neighbor_report_tx; |
| 172 | } rrm; |
| 173 | |
| 174 | struct { |
| 175 | u64 bss_transition_query_rx; |
| 176 | u64 bss_transition_request_tx; |
| 177 | u64 bss_transition_response_rx; |
| 178 | } wnm; |
| 179 | }; |
| 180 | |
| 181 | /** |
| 182 | * struct hostapd_data - hostapd per-BSS data structure |
| 183 | */ |
| 184 | struct hostapd_data { |
| 185 | struct hostapd_iface *iface; |
| 186 | struct hostapd_config *iconf; |
| 187 | struct hostapd_bss_config *conf; |
| 188 | struct hostapd_ubus_bss ubus; |
| 189 | char *config_id; |
| 190 | int interface_added; /* virtual interface added for this BSS */ |
| 191 | unsigned int started:1; |
| 192 | unsigned int disabled:1; |
| 193 | unsigned int reenable_beacon:1; |
| 194 | |
| 195 | u8 own_addr[ETH_ALEN]; |
| 196 | u8 mld_addr[ETH_ALEN]; |
| 197 | u8 mld_link_id; |
| 198 | /* Used for mld_link_id assignment - valid on the first MLD BSS only */ |
| 199 | u8 mld_next_link_id; |
| 200 | |
| 201 | struct hostapd_data *mld_first_bss; |
| 202 | |
| 203 | /* OpenWrt specific statistics */ |
| 204 | struct hostapd_openwrt_stats openwrt_stats; |
| 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 | struct radius_client_data *radius; |
| 230 | u64 acct_session_id; |
| 231 | struct radius_das_data *radius_das; |
| 232 | |
| 233 | struct hostapd_cached_radius_acl *acl_cache; |
| 234 | struct hostapd_acl_query_data *acl_queries; |
| 235 | |
| 236 | struct wpa_authenticator *wpa_auth; |
| 237 | struct eapol_authenticator *eapol_auth; |
| 238 | struct eap_config *eap_cfg; |
| 239 | |
| 240 | struct rsn_preauth_interface *preauth_iface; |
| 241 | struct os_reltime michael_mic_failure; |
| 242 | int michael_mic_failures; |
| 243 | int tkip_countermeasures; |
| 244 | |
| 245 | int ctrl_sock; |
| 246 | struct dl_list ctrl_dst; |
| 247 | |
| 248 | void *ssl_ctx; |
| 249 | void *eap_sim_db_priv; |
| 250 | struct crypto_rsa_key *imsi_privacy_key; |
| 251 | struct radius_server_data *radius_srv; |
| 252 | struct dl_list erp_keys; /* struct eap_server_erp_key */ |
| 253 | |
| 254 | int parameter_set_count; |
| 255 | |
| 256 | /* Time Advertisement */ |
| 257 | u8 time_update_counter; |
| 258 | struct wpabuf *time_adv; |
| 259 | |
| 260 | #ifdef CONFIG_FULL_DYNAMIC_VLAN |
| 261 | struct full_dynamic_vlan *full_dynamic_vlan; |
| 262 | #endif /* CONFIG_FULL_DYNAMIC_VLAN */ |
| 263 | |
| 264 | struct l2_packet_data *l2; |
| 265 | |
| 266 | #ifdef CONFIG_IEEE80211R_AP |
| 267 | struct dl_list l2_queue; |
| 268 | struct dl_list l2_oui_queue; |
| 269 | struct eth_p_oui_ctx *oui_pull; |
| 270 | struct eth_p_oui_ctx *oui_resp; |
| 271 | struct eth_p_oui_ctx *oui_push; |
| 272 | struct eth_p_oui_ctx *oui_sreq; |
| 273 | struct eth_p_oui_ctx *oui_sresp; |
| 274 | #endif /* CONFIG_IEEE80211R_AP */ |
| 275 | |
| 276 | struct wps_context *wps; |
| 277 | |
| 278 | int beacon_set_done; |
| 279 | struct wpabuf *wps_beacon_ie; |
| 280 | struct wpabuf *wps_probe_resp_ie; |
| 281 | #ifdef CONFIG_WPS |
| 282 | unsigned int ap_pin_failures; |
| 283 | unsigned int ap_pin_failures_consecutive; |
| 284 | struct upnp_wps_device_sm *wps_upnp; |
| 285 | unsigned int ap_pin_lockout_time; |
| 286 | |
| 287 | struct wps_stat wps_stats; |
| 288 | #endif /* CONFIG_WPS */ |
| 289 | |
| 290 | #ifdef CONFIG_MACSEC |
| 291 | struct ieee802_1x_kay *kay; |
| 292 | #endif /* CONFIG_MACSEC */ |
| 293 | |
| 294 | struct hostapd_probereq_cb *probereq_cb; |
| 295 | size_t num_probereq_cb; |
| 296 | |
| 297 | void (*public_action_cb)(void *ctx, const u8 *buf, size_t len, |
| 298 | int freq); |
| 299 | void *public_action_cb_ctx; |
| 300 | void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len, |
| 301 | int freq); |
| 302 | void *public_action_cb2_ctx; |
| 303 | |
| 304 | int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len, |
| 305 | int freq); |
| 306 | void *vendor_action_cb_ctx; |
| 307 | |
| 308 | void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr, |
| 309 | const u8 *uuid_e); |
| 310 | void *wps_reg_success_cb_ctx; |
| 311 | |
| 312 | void (*wps_event_cb)(void *ctx, enum wps_event event, |
| 313 | union wps_event_data *data); |
| 314 | void *wps_event_cb_ctx; |
| 315 | |
| 316 | void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr, |
| 317 | int authorized, const u8 *p2p_dev_addr); |
| 318 | void *sta_authorized_cb_ctx; |
| 319 | |
| 320 | void (*setup_complete_cb)(void *ctx); |
| 321 | void *setup_complete_cb_ctx; |
| 322 | |
| 323 | void (*new_psk_cb)(void *ctx, const u8 *mac_addr, |
| 324 | const u8 *p2p_dev_addr, const u8 *psk, |
| 325 | size_t psk_len); |
| 326 | void *new_psk_cb_ctx; |
| 327 | |
| 328 | /* channel switch parameters */ |
| 329 | struct hostapd_freq_params cs_freq_params; |
| 330 | u8 cs_count; |
| 331 | int cs_block_tx; |
| 332 | unsigned int cs_c_off_beacon; |
| 333 | unsigned int cs_c_off_proberesp; |
| 334 | int csa_in_progress; |
| 335 | unsigned int cs_c_off_ecsa_beacon; |
| 336 | unsigned int cs_c_off_ecsa_proberesp; |
| 337 | |
| 338 | #ifdef CONFIG_IEEE80211AX |
| 339 | bool cca_in_progress; |
| 340 | u8 cca_count; |
| 341 | u8 cca_color; |
| 342 | unsigned int cca_c_off_beacon; |
| 343 | unsigned int cca_c_off_proberesp; |
| 344 | struct os_reltime first_color_collision; |
| 345 | struct os_reltime last_color_collision; |
| 346 | u64 color_collision_bitmap; |
| 347 | #endif /* CONFIG_IEEE80211AX */ |
| 348 | |
| 349 | #ifdef CONFIG_P2P |
| 350 | struct p2p_data *p2p; |
| 351 | struct p2p_group *p2p_group; |
| 352 | struct wpabuf *p2p_beacon_ie; |
| 353 | struct wpabuf *p2p_probe_resp_ie; |
| 354 | |
| 355 | /* Number of non-P2P association stations */ |
| 356 | int num_sta_no_p2p; |
| 357 | |
| 358 | /* Periodic NoA (used only when no non-P2P clients in the group) */ |
| 359 | int noa_enabled; |
| 360 | int noa_start; |
| 361 | int noa_duration; |
| 362 | #endif /* CONFIG_P2P */ |
| 363 | #ifdef CONFIG_PROXYARP |
| 364 | struct l2_packet_data *sock_dhcp; |
| 365 | struct l2_packet_data *sock_ndisc; |
| 366 | bool x_snoop_initialized; |
| 367 | #endif /* CONFIG_PROXYARP */ |
| 368 | #ifdef CONFIG_MESH |
| 369 | int num_plinks; |
| 370 | int max_plinks; |
| 371 | void (*mesh_sta_free_cb)(struct hostapd_data *hapd, |
| 372 | struct sta_info *sta); |
| 373 | struct wpabuf *mesh_pending_auth; |
| 374 | struct os_reltime mesh_pending_auth_time; |
| 375 | u8 mesh_required_peer[ETH_ALEN]; |
| 376 | #endif /* CONFIG_MESH */ |
| 377 | |
| 378 | #ifdef CONFIG_SQLITE |
| 379 | struct hostapd_eap_user tmp_eap_user; |
| 380 | #endif /* CONFIG_SQLITE */ |
| 381 | |
| 382 | #ifdef CONFIG_SAE |
| 383 | |
| 384 | #define COMEBACK_KEY_SIZE 8 |
| 385 | #define COMEBACK_PENDING_IDX_SIZE 256 |
| 386 | |
| 387 | /** Key used for generating SAE anti-clogging tokens */ |
| 388 | u8 comeback_key[COMEBACK_KEY_SIZE]; |
| 389 | struct os_reltime last_comeback_key_update; |
| 390 | u16 comeback_idx; |
| 391 | u16 comeback_pending_idx[COMEBACK_PENDING_IDX_SIZE]; |
| 392 | int dot11RSNASAERetransPeriod; /* msec */ |
| 393 | struct dl_list sae_commit_queue; /* struct hostapd_sae_commit_queue */ |
| 394 | #endif /* CONFIG_SAE */ |
| 395 | |
| 396 | #ifdef CONFIG_TESTING_OPTIONS |
| 397 | unsigned int ext_mgmt_frame_handling:1; |
| 398 | unsigned int ext_eapol_frame_io:1; |
| 399 | |
| 400 | struct l2_packet_data *l2_test; |
| 401 | |
| 402 | enum wpa_alg last_gtk_alg; |
| 403 | int last_gtk_key_idx; |
| 404 | u8 last_gtk[WPA_GTK_MAX_LEN]; |
| 405 | size_t last_gtk_len; |
| 406 | |
| 407 | enum wpa_alg last_igtk_alg; |
| 408 | int last_igtk_key_idx; |
| 409 | u8 last_igtk[WPA_IGTK_MAX_LEN]; |
| 410 | size_t last_igtk_len; |
| 411 | |
| 412 | enum wpa_alg last_bigtk_alg; |
| 413 | int last_bigtk_key_idx; |
| 414 | u8 last_bigtk[WPA_BIGTK_MAX_LEN]; |
| 415 | size_t last_bigtk_len; |
| 416 | |
| 417 | bool force_backlog_bytes; |
| 418 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 419 | |
| 420 | #ifdef CONFIG_MBO |
| 421 | unsigned int mbo_assoc_disallow; |
| 422 | #endif /* CONFIG_MBO */ |
| 423 | |
| 424 | struct dl_list nr_db; |
| 425 | |
| 426 | u8 beacon_req_token; |
| 427 | u8 lci_req_token; |
| 428 | u8 range_req_token; |
| 429 | unsigned int lci_req_active:1; |
| 430 | unsigned int range_req_active:1; |
| 431 | |
| 432 | int dhcp_sock; /* UDP socket used with the DHCP server */ |
| 433 | |
| 434 | struct ptksa_cache *ptksa; |
| 435 | |
| 436 | #ifdef CONFIG_DPP |
| 437 | int dpp_init_done; |
| 438 | struct dpp_authentication *dpp_auth; |
| 439 | u8 dpp_allowed_roles; |
| 440 | int dpp_qr_mutual; |
| 441 | int dpp_auth_ok_on_ack; |
| 442 | int dpp_in_response_listen; |
| 443 | struct gas_query_ap *gas; |
| 444 | struct dpp_pkex *dpp_pkex; |
| 445 | struct dpp_bootstrap_info *dpp_pkex_bi; |
| 446 | char *dpp_pkex_code; |
| 447 | size_t dpp_pkex_code_len; |
| 448 | char *dpp_pkex_identifier; |
| 449 | enum dpp_pkex_ver dpp_pkex_ver; |
| 450 | char *dpp_pkex_auth_cmd; |
| 451 | char *dpp_configurator_params; |
| 452 | struct os_reltime dpp_last_init; |
| 453 | struct os_reltime dpp_init_iter_start; |
| 454 | unsigned int dpp_init_max_tries; |
| 455 | unsigned int dpp_init_retry_time; |
| 456 | unsigned int dpp_resp_wait_time; |
| 457 | unsigned int dpp_resp_max_tries; |
| 458 | unsigned int dpp_resp_retry_time; |
| 459 | #ifdef CONFIG_DPP2 |
| 460 | struct wpabuf *dpp_presence_announcement; |
| 461 | struct dpp_bootstrap_info *dpp_chirp_bi; |
| 462 | int dpp_chirp_freq; |
| 463 | int *dpp_chirp_freqs; |
| 464 | int dpp_chirp_iter; |
| 465 | int dpp_chirp_round; |
| 466 | int dpp_chirp_scan_done; |
| 467 | int dpp_chirp_listen; |
| 468 | struct os_reltime dpp_relay_last_needs_ctrl; |
| 469 | #endif /* CONFIG_DPP2 */ |
| 470 | #ifdef CONFIG_TESTING_OPTIONS |
| 471 | char *dpp_config_obj_override; |
| 472 | char *dpp_discovery_override; |
| 473 | char *dpp_groups_override; |
| 474 | unsigned int dpp_ignore_netaccesskey_mismatch:1; |
| 475 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 476 | #endif /* CONFIG_DPP */ |
| 477 | |
| 478 | #ifdef CONFIG_AIRTIME_POLICY |
| 479 | unsigned int num_backlogged_sta; |
| 480 | unsigned int airtime_weight; |
| 481 | #endif /* CONFIG_AIRTIME_POLICY */ |
| 482 | |
| 483 | u8 last_1x_eapol_key_replay_counter[8]; |
| 484 | |
| 485 | #ifdef CONFIG_SQLITE |
| 486 | sqlite3 *rad_attr_db; |
| 487 | #endif /* CONFIG_SQLITE */ |
| 488 | |
| 489 | #ifdef CONFIG_CTRL_IFACE_UDP |
| 490 | unsigned char ctrl_iface_cookie[CTRL_IFACE_COOKIE_LEN]; |
| 491 | #endif /* CONFIG_CTRL_IFACE_UDP */ |
| 492 | }; |
| 493 | |
| 494 | |
| 495 | struct hostapd_sta_info { |
| 496 | struct dl_list list; |
| 497 | u8 addr[ETH_ALEN]; |
| 498 | struct os_reltime last_seen; |
| 499 | int ssi_signal; |
| 500 | #ifdef CONFIG_TAXONOMY |
| 501 | struct wpabuf *probe_ie_taxonomy; |
| 502 | #endif /* CONFIG_TAXONOMY */ |
| 503 | }; |
| 504 | |
| 505 | /** |
| 506 | * struct hostapd_iface - hostapd per-interface data structure |
| 507 | */ |
| 508 | struct hostapd_iface { |
| 509 | struct hapd_interfaces *interfaces; |
| 510 | void *owner; |
| 511 | char *config_fname; |
| 512 | struct hostapd_config *conf; |
| 513 | char phy[16]; /* Name of the PHY (radio) */ |
| 514 | |
| 515 | enum hostapd_iface_state { |
| 516 | HAPD_IFACE_UNINITIALIZED, |
| 517 | HAPD_IFACE_DISABLED, |
| 518 | HAPD_IFACE_COUNTRY_UPDATE, |
| 519 | HAPD_IFACE_ACS, |
| 520 | HAPD_IFACE_HT_SCAN, |
| 521 | HAPD_IFACE_DFS, |
| 522 | HAPD_IFACE_NO_IR, |
| 523 | HAPD_IFACE_ENABLED |
| 524 | } state; |
| 525 | |
| 526 | #ifdef CONFIG_MESH |
| 527 | struct mesh_conf *mconf; |
| 528 | #endif /* CONFIG_MESH */ |
| 529 | |
| 530 | size_t num_bss; |
| 531 | struct hostapd_data **bss; |
| 532 | |
| 533 | unsigned int wait_channel_update:1; |
| 534 | unsigned int cac_started:1; |
| 535 | #ifdef CONFIG_FST |
| 536 | struct fst_iface *fst; |
| 537 | const struct wpabuf *fst_ies; |
| 538 | #endif /* CONFIG_FST */ |
| 539 | |
| 540 | /* |
| 541 | * When set, indicates that the driver will handle the AP |
| 542 | * teardown: delete global keys, station keys, and stations. |
| 543 | */ |
| 544 | unsigned int driver_ap_teardown:1; |
| 545 | |
| 546 | /* |
| 547 | * When set, indicates that this interface is part of list of |
| 548 | * interfaces that need to be started together (synchronously). |
| 549 | */ |
| 550 | unsigned int need_to_start_in_sync:1; |
| 551 | |
| 552 | /* Ready to start but waiting for other interfaces to become ready. */ |
| 553 | unsigned int ready_to_start_in_sync:1; |
| 554 | |
| 555 | int num_ap; /* number of entries in ap_list */ |
| 556 | #ifdef CONFIG_5G_BW_SWITCH |
| 557 | int max_rssi; /* maximum RSSI level of co-channel APs. Added by Liangyu Chu */ |
| 558 | #endif /* CONFIG_5G_BW_SWITCH */ |
| 559 | struct ap_info *ap_list; /* AP info list head */ |
| 560 | struct ap_info *ap_hash[STA_HASH_SIZE]; |
| 561 | |
| 562 | u64 drv_flags; |
| 563 | u64 drv_flags2; |
| 564 | |
| 565 | /* |
| 566 | * A bitmap of supported protocols for probe response offload. See |
| 567 | * struct wpa_driver_capa in driver.h |
| 568 | */ |
| 569 | unsigned int probe_resp_offloads; |
| 570 | |
| 571 | /* extended capabilities supported by the driver */ |
| 572 | const u8 *extended_capa, *extended_capa_mask; |
| 573 | unsigned int extended_capa_len; |
| 574 | |
| 575 | u16 mld_eml_capa, mld_mld_capa; |
| 576 | |
| 577 | unsigned int drv_max_acl_mac_addrs; |
| 578 | |
| 579 | struct hostapd_hw_modes *hw_features; |
| 580 | int num_hw_features; |
| 581 | struct hostapd_hw_modes *current_mode; |
| 582 | /* Rates that are currently used (i.e., filtered copy of |
| 583 | * current_mode->channels */ |
| 584 | int num_rates; |
| 585 | struct hostapd_rate_data *current_rates; |
| 586 | int *basic_rates; |
| 587 | int freq; |
| 588 | |
| 589 | /* Background radar configuration */ |
| 590 | struct { |
| 591 | int channel; |
| 592 | int secondary_channel; |
| 593 | int freq; |
| 594 | int centr_freq_seg0_idx; |
| 595 | int centr_freq_seg1_idx; |
| 596 | /* Main chain is on temporary channel during |
| 597 | * CAC detection on radar offchain. |
| 598 | */ |
| 599 | unsigned int temp_ch:1; |
| 600 | /* CAC started on radar offchain */ |
| 601 | unsigned int cac_started:1; |
| 602 | } radar_background; |
| 603 | |
| 604 | u16 hw_flags; |
| 605 | |
| 606 | /* Number of associated Non-ERP stations (i.e., stations using 802.11b |
| 607 | * in 802.11g BSS) */ |
| 608 | int num_sta_non_erp; |
| 609 | |
| 610 | /* Number of associated stations that do not support Short Slot Time */ |
| 611 | int num_sta_no_short_slot_time; |
| 612 | |
| 613 | /* Number of associated stations that do not support Short Preamble */ |
| 614 | int num_sta_no_short_preamble; |
| 615 | |
| 616 | int olbc; /* Overlapping Legacy BSS Condition */ |
| 617 | |
| 618 | /* Number of HT associated stations that do not support greenfield */ |
| 619 | int num_sta_ht_no_gf; |
| 620 | |
| 621 | /* Number of associated non-HT stations */ |
| 622 | int num_sta_no_ht; |
| 623 | |
| 624 | /* Number of HT associated stations 20 MHz */ |
| 625 | int num_sta_ht_20mhz; |
| 626 | |
| 627 | /* Number of HT40 intolerant stations */ |
| 628 | int num_sta_ht40_intolerant; |
| 629 | |
| 630 | /* Overlapping BSS information */ |
| 631 | int olbc_ht; |
| 632 | |
| 633 | u16 ht_op_mode; |
| 634 | |
| 635 | /* surveying helpers */ |
| 636 | |
| 637 | /* number of channels surveyed */ |
| 638 | unsigned int chans_surveyed; |
| 639 | |
| 640 | /* lowest observed noise floor in dBm */ |
| 641 | s8 lowest_nf; |
| 642 | |
| 643 | /* channel utilization calculation */ |
| 644 | u64 last_channel_time; |
| 645 | u64 last_channel_time_busy; |
| 646 | u8 channel_utilization; |
| 647 | |
| 648 | unsigned int chan_util_samples_sum; |
| 649 | unsigned int chan_util_num_sample_periods; |
| 650 | unsigned int chan_util_average; |
| 651 | |
| 652 | /* eCSA IE will be added only if operating class is specified */ |
| 653 | u8 cs_oper_class; |
| 654 | |
| 655 | unsigned int dfs_cac_ms; |
| 656 | struct os_reltime dfs_cac_start; |
| 657 | |
| 658 | /* Latched with the actual secondary channel information and will be |
| 659 | * used while juggling between HT20 and HT40 modes. */ |
| 660 | int secondary_ch; |
| 661 | #ifdef CONFIG_5G_BW_SWITCH |
| 662 | // Record VHT operation channel bandwidth. Added by Liangyu Chu |
| 663 | u8 vht_oper_ch_bw; |
| 664 | // Record VHT operation center_freq_seg0_index for 80M bandwidth |
| 665 | u8 vht_center_freq_seg0_80m; |
| 666 | // Record VHT operation center_freq_seg0_index for 40M bandwidth |
| 667 | u8 vht_center_freq_seg0_40m; |
| 668 | #endif /* CONFIG_5G_BW_SWITCH */ |
| 669 | |
| 670 | #ifdef CONFIG_ACS |
| 671 | unsigned int acs_num_completed_scans; |
| 672 | #endif /* CONFIG_ACS */ |
| 673 | |
| 674 | void (*scan_cb)(struct hostapd_iface *iface); |
| 675 | int num_ht40_scan_tries; |
| 676 | |
| 677 | struct dl_list sta_seen; /* struct hostapd_sta_info */ |
| 678 | unsigned int num_sta_seen; |
| 679 | |
| 680 | u8 dfs_domain; |
| 681 | #ifdef CONFIG_AIRTIME_POLICY |
| 682 | unsigned int airtime_quantum; |
| 683 | #endif /* CONFIG_AIRTIME_POLICY */ |
| 684 | |
| 685 | /* Previous WMM element information */ |
| 686 | struct hostapd_wmm_ac_params prev_wmm[WMM_AC_NUM]; |
| 687 | |
| 688 | /* Maximum number of interfaces supported for MBSSID advertisement */ |
| 689 | unsigned int mbssid_max_interfaces; |
| 690 | /* Maximum profile periodicity for enhanced MBSSID advertisement */ |
| 691 | unsigned int ema_max_periodicity; |
| 692 | |
| 693 | int (*enable_iface_cb)(struct hostapd_iface *iface); |
| 694 | int (*disable_iface_cb)(struct hostapd_iface *iface); |
| 695 | |
| 696 | /* Configured freq of interface is NO_IR */ |
| 697 | bool is_no_ir; |
| 698 | }; |
| 699 | |
| 700 | /* hostapd.c */ |
| 701 | int hostapd_for_each_interface(struct hapd_interfaces *interfaces, |
| 702 | int (*cb)(struct hostapd_iface *iface, |
| 703 | void *ctx), void *ctx); |
| 704 | int hostapd_reload_config(struct hostapd_iface *iface, int reconf); |
| 705 | void hostapd_reconfig_encryption(struct hostapd_data *hapd); |
| 706 | struct hostapd_data * |
| 707 | hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, |
| 708 | struct hostapd_config *conf, |
| 709 | struct hostapd_bss_config *bss); |
| 710 | int hostapd_setup_interface(struct hostapd_iface *iface); |
| 711 | int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err); |
| 712 | void hostapd_set_own_neighbor_report(struct hostapd_data *hapd); |
| 713 | void hostapd_interface_deinit(struct hostapd_iface *iface); |
| 714 | void hostapd_interface_free(struct hostapd_iface *iface); |
| 715 | struct hostapd_iface * hostapd_alloc_iface(void); |
| 716 | struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces, |
| 717 | const char *config_file); |
| 718 | struct hostapd_iface * |
| 719 | hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy, |
| 720 | const char *config_fname, int debug); |
| 721 | void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, |
| 722 | int reassoc); |
| 723 | void hostapd_interface_deinit_free(struct hostapd_iface *iface); |
| 724 | int hostapd_enable_iface(struct hostapd_iface *hapd_iface); |
| 725 | int hostapd_reload_iface(struct hostapd_iface *hapd_iface); |
| 726 | int hostapd_reload_bss_only(struct hostapd_data *bss); |
| 727 | int hostapd_disable_iface(struct hostapd_iface *hapd_iface); |
| 728 | void hostapd_bss_deinit_no_free(struct hostapd_data *hapd); |
| 729 | void hostapd_free_hapd_data(struct hostapd_data *hapd); |
| 730 | void hostapd_cleanup_iface_partial(struct hostapd_iface *iface); |
| 731 | int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf); |
| 732 | int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf); |
| 733 | void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator); |
| 734 | void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s); |
| 735 | const char * hostapd_state_text(enum hostapd_iface_state s); |
| 736 | int hostapd_csa_in_progress(struct hostapd_iface *iface); |
| 737 | void hostapd_chan_switch_config(struct hostapd_data *hapd, |
| 738 | struct hostapd_freq_params *freq_params); |
| 739 | int hostapd_switch_channel(struct hostapd_data *hapd, |
| 740 | struct csa_settings *settings); |
| 741 | void |
| 742 | hostapd_switch_channel_fallback(struct hostapd_iface *iface, |
| 743 | const struct hostapd_freq_params *freq_params); |
| 744 | void hostapd_cleanup_cs_params(struct hostapd_data *hapd); |
| 745 | void hostapd_periodic_iface(struct hostapd_iface *iface); |
| 746 | int hostapd_owe_trans_get_info(struct hostapd_data *hapd); |
| 747 | void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx); |
| 748 | int hostapd_check_max_sta(struct hostapd_data *hapd); |
| 749 | |
| 750 | void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap); |
| 751 | void hostapd_cleanup_cca_params(struct hostapd_data *hapd); |
| 752 | |
| 753 | /* utils.c */ |
| 754 | int hostapd_register_probereq_cb(struct hostapd_data *hapd, |
| 755 | int (*cb)(void *ctx, const u8 *sa, |
| 756 | const u8 *da, const u8 *bssid, |
| 757 | const u8 *ie, size_t ie_len, |
| 758 | int ssi_signal), |
| 759 | void *ctx); |
| 760 | void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr, |
| 761 | int mld_assoc_link_id); |
| 762 | |
| 763 | /* drv_callbacks.c (TODO: move to somewhere else?) */ |
| 764 | void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd, |
| 765 | struct sta_info *sta); |
| 766 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, |
| 767 | const u8 *ie, size_t ielen, int reassoc); |
| 768 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr); |
| 769 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr); |
| 770 | void hostapd_event_connect_failed_reason(struct hostapd_data *hapd, |
| 771 | const u8 *addr, int reason_code); |
| 772 | int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, |
| 773 | const u8 *bssid, const u8 *ie, size_t ie_len, |
| 774 | int ssi_signal); |
| 775 | void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, |
| 776 | int offset, int width, int cf1, int cf2, |
| 777 | u16 punct_bitmap, int finished); |
| 778 | struct survey_results; |
| 779 | void hostapd_event_get_survey(struct hostapd_iface *iface, |
| 780 | struct survey_results *survey_results); |
| 781 | void hostapd_acs_channel_selected(struct hostapd_data *hapd, |
| 782 | struct acs_selected_channels *acs_res); |
| 783 | |
| 784 | const struct hostapd_eap_user * |
| 785 | hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity, |
| 786 | size_t identity_len, int phase2); |
| 787 | |
| 788 | struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces, |
| 789 | const char *ifname); |
| 790 | void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr, |
| 791 | enum smps_mode smps_mode, |
| 792 | enum chan_width chan_width, u8 rx_nss); |
| 793 | |
| 794 | #ifdef CONFIG_FST |
| 795 | void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd, |
| 796 | struct fst_wpa_obj *iface_obj); |
| 797 | #endif /* CONFIG_FST */ |
| 798 | |
| 799 | int hostapd_set_acl(struct hostapd_data *hapd); |
| 800 | struct hostapd_data * hostapd_mbssid_get_tx_bss(struct hostapd_data *hapd); |
| 801 | int hostapd_mbssid_get_bss_index(struct hostapd_data *hapd); |
| 802 | struct hostapd_data * hostapd_mld_get_link_bss(struct hostapd_data *hapd, |
| 803 | u8 link_id); |
| 804 | |
| 805 | #endif /* HOSTAPD_H */ |