2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "common/defs.h"
13 #include "utils/list.h"
14 #include "ap_config.h"
15 #include "drivers/driver.h"
18 struct radius_server_data
;
19 struct upnp_wps_device_sm
;
22 struct ieee80211_ht_capabilities
;
23 struct full_dynamic_vlan
;
28 #endif /* CONFIG_MESH */
32 struct hapd_interfaces
{
33 int (*reload_config
)(struct hostapd_iface
*iface
);
34 struct hostapd_config
* (*config_read_cb
)(const char *config_fname
);
35 int (*ctrl_iface_init
)(struct hostapd_data
*hapd
);
36 void (*ctrl_iface_deinit
)(struct hostapd_data
*hapd
);
37 int (*for_each_interface
)(struct hapd_interfaces
*interfaces
,
38 int (*cb
)(struct hostapd_iface
*iface
,
39 void *ctx
), void *ctx
);
40 int (*driver_init
)(struct hostapd_iface
*iface
);
44 struct dl_list global_ctrl_dst
;
45 char *global_iface_path
;
46 char *global_iface_name
;
47 #ifndef CONFIG_NATIVE_WINDOWS
48 gid_t ctrl_iface_group
;
49 #endif /* CONFIG_NATIVE_WINDOWS */
50 struct hostapd_iface
**iface
;
52 size_t terminate_on_error
;
53 #ifndef CONFIG_NO_VLAN
54 struct dynamic_iface
*vlan_priv
;
55 #endif /* CONFIG_NO_VLAN */
56 #ifdef CONFIG_ETH_P_OUI
57 struct dl_list eth_p_oui
; /* OUI Extended EtherType handlers */
58 #endif /* CONFIG_ETH_P_OUI */
59 int eloop_initialized
;
63 struct dl_list dpp_bootstrap
; /* struct dpp_bootstrap_info */
64 struct dl_list dpp_configurator
; /* struct dpp_configurator */
65 #endif /* CONFIG_DPP */
68 enum hostapd_chan_status
{
69 HOSTAPD_CHAN_VALID
= 0, /* channel is ready */
70 HOSTAPD_CHAN_INVALID
= 1, /* no usable channel found */
71 HOSTAPD_CHAN_ACS
= 2, /* ACS work being performed */
74 struct hostapd_probereq_cb
{
75 int (*cb
)(void *ctx
, const u8
*sa
, const u8
*da
, const u8
*bssid
,
76 const u8
*ie
, size_t ie_len
, int ssi_signal
);
80 #define HOSTAPD_RATE_BASIC 0x00000001
82 struct hostapd_rate_data
{
83 int rate
; /* rate in 100 kbps */
84 int flags
; /* HOSTAPD_RATE_ flags */
87 struct hostapd_frame_info
{
91 int ssi_signal
; /* dBm */
95 WPS_STATUS_SUCCESS
= 1,
100 WPS_PBC_STATUS_DISABLE
,
101 WPS_PBC_STATUS_ACTIVE
,
102 WPS_PBC_STATUS_TIMEOUT
,
103 WPS_PBC_STATUS_OVERLAP
107 enum wps_status status
;
108 enum wps_error_indication failure_reason
;
109 enum pbc_status pbc_status
;
110 u8 peer_addr
[ETH_ALEN
];
113 struct hostapd_neighbor_entry
{
116 struct wpa_ssid_value ssid
;
119 struct wpabuf
*civic
;
120 /* LCI update time */
121 struct os_time lci_date
;
126 * struct hostapd_data - hostapd per-BSS data structure
128 struct hostapd_data
{
129 struct hostapd_iface
*iface
;
130 struct hostapd_config
*iconf
;
131 struct hostapd_bss_config
*conf
;
132 int interface_added
; /* virtual interface added for this BSS */
133 unsigned int started
:1;
134 unsigned int disabled
:1;
135 unsigned int reenable_beacon
:1;
137 u8 own_addr
[ETH_ALEN
];
139 int num_sta
; /* number of entries in sta_list */
140 struct sta_info
*sta_list
; /* STA info list head */
141 #define STA_HASH_SIZE 256
142 #define STA_HASH(sta) (sta[5])
143 struct sta_info
*sta_hash
[STA_HASH_SIZE
];
146 * Bitfield for indicating which AIDs are allocated. Only AID values
147 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
150 #define AID_WORDS ((2008 + 31) / 32)
151 u32 sta_aid
[AID_WORDS
];
153 const struct wpa_driver_ops
*driver
;
156 void (*new_assoc_sta_cb
)(struct hostapd_data
*hapd
,
157 struct sta_info
*sta
, int reassoc
);
159 void *msg_ctx
; /* ctx for wpa_msg() calls */
160 void *msg_ctx_parent
; /* parent interface ctx for wpa_msg() calls */
162 struct radius_client_data
*radius
;
164 struct radius_das_data
*radius_das
;
166 struct iapp_data
*iapp
;
168 struct hostapd_cached_radius_acl
*acl_cache
;
169 struct hostapd_acl_query_data
*acl_queries
;
171 struct wpa_authenticator
*wpa_auth
;
172 struct eapol_authenticator
*eapol_auth
;
174 struct rsn_preauth_interface
*preauth_iface
;
175 struct os_reltime michael_mic_failure
;
176 int michael_mic_failures
;
177 int tkip_countermeasures
;
180 struct dl_list ctrl_dst
;
183 void *eap_sim_db_priv
;
184 struct radius_server_data
*radius_srv
;
185 struct dl_list erp_keys
; /* struct eap_server_erp_key */
187 int parameter_set_count
;
189 /* Time Advertisement */
190 u8 time_update_counter
;
191 struct wpabuf
*time_adv
;
193 #ifdef CONFIG_FULL_DYNAMIC_VLAN
194 struct full_dynamic_vlan
*full_dynamic_vlan
;
195 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
197 struct l2_packet_data
*l2
;
199 #ifdef CONFIG_IEEE80211R_AP
200 struct dl_list l2_queue
;
201 struct dl_list l2_oui_queue
;
202 struct eth_p_oui_ctx
*oui_pull
;
203 struct eth_p_oui_ctx
*oui_resp
;
204 struct eth_p_oui_ctx
*oui_push
;
205 struct eth_p_oui_ctx
*oui_sreq
;
206 struct eth_p_oui_ctx
*oui_sresp
;
207 #endif /* CONFIG_IEEE80211R_AP */
209 struct wps_context
*wps
;
212 struct wpabuf
*wps_beacon_ie
;
213 struct wpabuf
*wps_probe_resp_ie
;
215 unsigned int ap_pin_failures
;
216 unsigned int ap_pin_failures_consecutive
;
217 struct upnp_wps_device_sm
*wps_upnp
;
218 unsigned int ap_pin_lockout_time
;
220 struct wps_stat wps_stats
;
221 #endif /* CONFIG_WPS */
223 struct hostapd_probereq_cb
*probereq_cb
;
224 size_t num_probereq_cb
;
226 void (*public_action_cb
)(void *ctx
, const u8
*buf
, size_t len
,
228 void *public_action_cb_ctx
;
229 void (*public_action_cb2
)(void *ctx
, const u8
*buf
, size_t len
,
231 void *public_action_cb2_ctx
;
233 int (*vendor_action_cb
)(void *ctx
, const u8
*buf
, size_t len
,
235 void *vendor_action_cb_ctx
;
237 void (*wps_reg_success_cb
)(void *ctx
, const u8
*mac_addr
,
239 void *wps_reg_success_cb_ctx
;
241 void (*wps_event_cb
)(void *ctx
, enum wps_event event
,
242 union wps_event_data
*data
);
243 void *wps_event_cb_ctx
;
245 void (*sta_authorized_cb
)(void *ctx
, const u8
*mac_addr
,
246 int authorized
, const u8
*p2p_dev_addr
);
247 void *sta_authorized_cb_ctx
;
249 void (*setup_complete_cb
)(void *ctx
);
250 void *setup_complete_cb_ctx
;
252 void (*new_psk_cb
)(void *ctx
, const u8
*mac_addr
,
253 const u8
*p2p_dev_addr
, const u8
*psk
,
255 void *new_psk_cb_ctx
;
257 /* channel switch parameters */
258 struct hostapd_freq_params cs_freq_params
;
261 unsigned int cs_c_off_beacon
;
262 unsigned int cs_c_off_proberesp
;
264 unsigned int cs_c_off_ecsa_beacon
;
265 unsigned int cs_c_off_ecsa_proberesp
;
268 struct p2p_data
*p2p
;
269 struct p2p_group
*p2p_group
;
270 struct wpabuf
*p2p_beacon_ie
;
271 struct wpabuf
*p2p_probe_resp_ie
;
273 /* Number of non-P2P association stations */
276 /* Periodic NoA (used only when no non-P2P clients in the group) */
280 #endif /* CONFIG_P2P */
281 #ifdef CONFIG_PROXYARP
282 struct l2_packet_data
*sock_dhcp
;
283 struct l2_packet_data
*sock_ndisc
;
284 #endif /* CONFIG_PROXYARP */
288 void (*mesh_sta_free_cb
)(struct hostapd_data
*hapd
,
289 struct sta_info
*sta
);
290 struct wpabuf
*mesh_pending_auth
;
291 struct os_reltime mesh_pending_auth_time
;
292 u8 mesh_required_peer
[ETH_ALEN
];
293 #endif /* CONFIG_MESH */
296 struct hostapd_eap_user tmp_eap_user
;
297 #endif /* CONFIG_SQLITE */
300 /** Key used for generating SAE anti-clogging tokens */
302 struct os_reltime last_sae_token_key_update
;
303 int dot11RSNASAERetransPeriod
; /* msec */
304 #endif /* CONFIG_SAE */
306 #ifdef CONFIG_TESTING_OPTIONS
307 unsigned int ext_mgmt_frame_handling
:1;
308 unsigned int ext_eapol_frame_io
:1;
310 struct l2_packet_data
*l2_test
;
312 enum wpa_alg last_gtk_alg
;
313 int last_gtk_key_idx
;
314 u8 last_gtk
[WPA_GTK_MAX_LEN
];
317 #ifdef CONFIG_IEEE80211W
318 enum wpa_alg last_igtk_alg
;
319 int last_igtk_key_idx
;
320 u8 last_igtk
[WPA_IGTK_MAX_LEN
];
321 size_t last_igtk_len
;
322 #endif /* CONFIG_IEEE80211W */
323 #endif /* CONFIG_TESTING_OPTIONS */
326 unsigned int mbo_assoc_disallow
;
328 * enable_oce - Enable OCE if it is enabled by user and device also
332 #endif /* CONFIG_MBO */
334 struct dl_list nr_db
;
339 unsigned int lci_req_active
:1;
340 unsigned int range_req_active
:1;
342 int dhcp_sock
; /* UDP socket used with the DHCP server */
346 struct dpp_authentication
*dpp_auth
;
347 u8 dpp_allowed_roles
;
349 int dpp_auth_ok_on_ack
;
350 int dpp_in_response_listen
;
351 struct gas_query_ap
*gas
;
352 struct dpp_pkex
*dpp_pkex
;
353 struct dpp_bootstrap_info
*dpp_pkex_bi
;
355 char *dpp_pkex_identifier
;
356 char *dpp_pkex_auth_cmd
;
357 char *dpp_configurator_params
;
358 struct os_reltime dpp_last_init
;
359 struct os_reltime dpp_init_iter_start
;
360 unsigned int dpp_init_max_tries
;
361 unsigned int dpp_init_retry_time
;
362 unsigned int dpp_resp_wait_time
;
363 unsigned int dpp_resp_max_tries
;
364 unsigned int dpp_resp_retry_time
;
365 #ifdef CONFIG_TESTING_OPTIONS
366 char *dpp_config_obj_override
;
367 char *dpp_discovery_override
;
368 char *dpp_groups_override
;
369 unsigned int dpp_ignore_netaccesskey_mismatch
:1;
370 #endif /* CONFIG_TESTING_OPTIONS */
371 #endif /* CONFIG_DPP */
375 struct hostapd_sta_info
{
378 struct os_reltime last_seen
;
380 #ifdef CONFIG_TAXONOMY
381 struct wpabuf
*probe_ie_taxonomy
;
382 #endif /* CONFIG_TAXONOMY */
386 * struct hostapd_iface - hostapd per-interface data structure
388 struct hostapd_iface
{
389 struct hapd_interfaces
*interfaces
;
392 struct hostapd_config
*conf
;
393 char phy
[16]; /* Name of the PHY (radio) */
395 enum hostapd_iface_state
{
396 HAPD_IFACE_UNINITIALIZED
,
398 HAPD_IFACE_COUNTRY_UPDATE
,
406 struct mesh_conf
*mconf
;
407 #endif /* CONFIG_MESH */
410 struct hostapd_data
**bss
;
412 unsigned int wait_channel_update
:1;
413 unsigned int cac_started
:1;
415 struct fst_iface
*fst
;
416 const struct wpabuf
*fst_ies
;
417 #endif /* CONFIG_FST */
420 * When set, indicates that the driver will handle the AP
421 * teardown: delete global keys, station keys, and stations.
423 unsigned int driver_ap_teardown
:1;
426 * When set, indicates that this interface is part of list of
427 * interfaces that need to be started together (synchronously).
429 unsigned int need_to_start_in_sync
:1;
431 /* Ready to start but waiting for other interfaces to become ready. */
432 unsigned int ready_to_start_in_sync
:1;
434 int num_ap
; /* number of entries in ap_list */
435 struct ap_info
*ap_list
; /* AP info list head */
436 struct ap_info
*ap_hash
[STA_HASH_SIZE
];
440 /* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */
441 unsigned int smps_modes
;
444 * A bitmap of supported protocols for probe response offload. See
445 * struct wpa_driver_capa in driver.h
447 unsigned int probe_resp_offloads
;
449 /* extended capabilities supported by the driver */
450 const u8
*extended_capa
, *extended_capa_mask
;
451 unsigned int extended_capa_len
;
453 unsigned int drv_max_acl_mac_addrs
;
455 struct hostapd_hw_modes
*hw_features
;
457 struct hostapd_hw_modes
*current_mode
;
458 /* Rates that are currently used (i.e., filtered copy of
459 * current_mode->channels */
461 struct hostapd_rate_data
*current_rates
;
467 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
471 /* Number of associated stations that do not support Short Slot Time */
472 int num_sta_no_short_slot_time
;
474 /* Number of associated stations that do not support Short Preamble */
475 int num_sta_no_short_preamble
;
477 int olbc
; /* Overlapping Legacy BSS Condition */
479 /* Number of HT associated stations that do not support greenfield */
480 int num_sta_ht_no_gf
;
482 /* Number of associated non-HT stations */
485 /* Number of HT associated stations 20 MHz */
486 int num_sta_ht_20mhz
;
488 /* Number of HT40 intolerant stations */
489 int num_sta_ht40_intolerant
;
491 /* Overlapping BSS information */
496 /* surveying helpers */
498 /* number of channels surveyed */
499 unsigned int chans_surveyed
;
501 /* lowest observed noise floor in dBm */
504 /* channel utilization calculation */
505 u64 last_channel_time
;
506 u64 last_channel_time_busy
;
507 u8 channel_utilization
;
509 unsigned int chan_util_samples_sum
;
510 unsigned int chan_util_num_sample_periods
;
511 unsigned int chan_util_average
;
513 /* eCSA IE will be added only if operating class is specified */
516 unsigned int dfs_cac_ms
;
517 struct os_reltime dfs_cac_start
;
519 /* Latched with the actual secondary channel information and will be
520 * used while juggling between HT20 and HT40 modes. */
524 unsigned int acs_num_completed_scans
;
525 #endif /* CONFIG_ACS */
527 void (*scan_cb
)(struct hostapd_iface
*iface
);
528 int num_ht40_scan_tries
;
530 struct dl_list sta_seen
; /* struct hostapd_sta_info */
531 unsigned int num_sta_seen
;
537 int hostapd_for_each_interface(struct hapd_interfaces
*interfaces
,
538 int (*cb
)(struct hostapd_iface
*iface
,
539 void *ctx
), void *ctx
);
540 int hostapd_reload_config(struct hostapd_iface
*iface
);
541 struct hostapd_data
*
542 hostapd_alloc_bss_data(struct hostapd_iface
*hapd_iface
,
543 struct hostapd_config
*conf
,
544 struct hostapd_bss_config
*bss
);
545 int hostapd_setup_interface(struct hostapd_iface
*iface
);
546 int hostapd_setup_interface_complete(struct hostapd_iface
*iface
, int err
);
547 void hostapd_interface_deinit(struct hostapd_iface
*iface
);
548 void hostapd_interface_free(struct hostapd_iface
*iface
);
549 struct hostapd_iface
* hostapd_alloc_iface(void);
550 struct hostapd_iface
* hostapd_init(struct hapd_interfaces
*interfaces
,
551 const char *config_file
);
552 struct hostapd_iface
*
553 hostapd_interface_init_bss(struct hapd_interfaces
*interfaces
, const char *phy
,
554 const char *config_fname
, int debug
);
555 void hostapd_new_assoc_sta(struct hostapd_data
*hapd
, struct sta_info
*sta
,
557 void hostapd_interface_deinit_free(struct hostapd_iface
*iface
);
558 int hostapd_enable_iface(struct hostapd_iface
*hapd_iface
);
559 int hostapd_reload_iface(struct hostapd_iface
*hapd_iface
);
560 int hostapd_disable_iface(struct hostapd_iface
*hapd_iface
);
561 int hostapd_add_iface(struct hapd_interfaces
*ifaces
, char *buf
);
562 int hostapd_remove_iface(struct hapd_interfaces
*ifaces
, char *buf
);
563 void hostapd_channel_list_updated(struct hostapd_iface
*iface
, int initiator
);
564 void hostapd_set_state(struct hostapd_iface
*iface
, enum hostapd_iface_state s
);
565 const char * hostapd_state_text(enum hostapd_iface_state s
);
566 int hostapd_csa_in_progress(struct hostapd_iface
*iface
);
567 void hostapd_chan_switch_vht_config(struct hostapd_data
*hapd
, int vht_enabled
);
568 int hostapd_switch_channel(struct hostapd_data
*hapd
,
569 struct csa_settings
*settings
);
571 hostapd_switch_channel_fallback(struct hostapd_iface
*iface
,
572 const struct hostapd_freq_params
*freq_params
);
573 void hostapd_cleanup_cs_params(struct hostapd_data
*hapd
);
574 void hostapd_periodic_iface(struct hostapd_iface
*iface
);
575 int hostapd_owe_trans_get_info(struct hostapd_data
*hapd
);
578 int hostapd_register_probereq_cb(struct hostapd_data
*hapd
,
579 int (*cb
)(void *ctx
, const u8
*sa
,
580 const u8
*da
, const u8
*bssid
,
581 const u8
*ie
, size_t ie_len
,
584 void hostapd_prune_associations(struct hostapd_data
*hapd
, const u8
*addr
);
586 /* drv_callbacks.c (TODO: move to somewhere else?) */
587 void hostapd_notify_assoc_fils_finish(struct hostapd_data
*hapd
,
588 struct sta_info
*sta
);
589 int hostapd_notif_assoc(struct hostapd_data
*hapd
, const u8
*addr
,
590 const u8
*ie
, size_t ielen
, int reassoc
);
591 void hostapd_notif_disassoc(struct hostapd_data
*hapd
, const u8
*addr
);
592 void hostapd_event_sta_low_ack(struct hostapd_data
*hapd
, const u8
*addr
);
593 void hostapd_event_connect_failed_reason(struct hostapd_data
*hapd
,
594 const u8
*addr
, int reason_code
);
595 int hostapd_probe_req_rx(struct hostapd_data
*hapd
, const u8
*sa
, const u8
*da
,
596 const u8
*bssid
, const u8
*ie
, size_t ie_len
,
598 void hostapd_event_ch_switch(struct hostapd_data
*hapd
, int freq
, int ht
,
599 int offset
, int width
, int cf1
, int cf2
);
600 struct survey_results
;
601 void hostapd_event_get_survey(struct hostapd_iface
*iface
,
602 struct survey_results
*survey_results
);
603 void hostapd_acs_channel_selected(struct hostapd_data
*hapd
,
604 struct acs_selected_channels
*acs_res
);
606 const struct hostapd_eap_user
*
607 hostapd_get_eap_user(struct hostapd_data
*hapd
, const u8
*identity
,
608 size_t identity_len
, int phase2
);
610 struct hostapd_data
* hostapd_get_iface(struct hapd_interfaces
*interfaces
,
612 void hostapd_event_sta_opmode_changed(struct hostapd_data
*hapd
, const u8
*addr
,
613 enum smps_mode smps_mode
,
614 enum chan_width chan_width
, u8 rx_nss
);
617 void fst_hostapd_fill_iface_obj(struct hostapd_data
*hapd
,
618 struct fst_wpa_obj
*iface_obj
);
619 #endif /* CONFIG_FST */
621 #endif /* HOSTAPD_H */