]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/ap/hostapd.h
hostapd: Fix CHAN_SWITCH command for VHT20 and VHT40
[thirdparty/hostap.git] / src / ap / hostapd.h
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 #include "common/defs.h"
13 #include "utils/list.h"
14 #include "ap_config.h"
15 #include "drivers/driver.h"
16
17 struct wpa_ctrl_dst;
18 struct radius_server_data;
19 struct upnp_wps_device_sm;
20 struct hostapd_data;
21 struct sta_info;
22 struct ieee80211_ht_capabilities;
23 struct full_dynamic_vlan;
24 enum wps_event;
25 union wps_event_data;
26 #ifdef CONFIG_MESH
27 struct mesh_conf;
28 #endif /* CONFIG_MESH */
29
30 struct hostapd_iface;
31
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);
41
42 size_t count;
43 int global_ctrl_sock;
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;
51
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;
60
61 #ifdef CONFIG_DPP
62 int dpp_init_done;
63 struct dl_list dpp_bootstrap; /* struct dpp_bootstrap_info */
64 struct dl_list dpp_configurator; /* struct dpp_configurator */
65 #endif /* CONFIG_DPP */
66 };
67
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 */
72 };
73
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);
77 void *ctx;
78 };
79
80 #define HOSTAPD_RATE_BASIC 0x00000001
81
82 struct hostapd_rate_data {
83 int rate; /* rate in 100 kbps */
84 int flags; /* HOSTAPD_RATE_ flags */
85 };
86
87 struct hostapd_frame_info {
88 unsigned int freq;
89 u32 channel;
90 u32 datarate;
91 int ssi_signal; /* dBm */
92 };
93
94 enum wps_status {
95 WPS_STATUS_SUCCESS = 1,
96 WPS_STATUS_FAILURE
97 };
98
99 enum pbc_status {
100 WPS_PBC_STATUS_DISABLE,
101 WPS_PBC_STATUS_ACTIVE,
102 WPS_PBC_STATUS_TIMEOUT,
103 WPS_PBC_STATUS_OVERLAP
104 };
105
106 struct wps_stat {
107 enum wps_status status;
108 enum wps_error_indication failure_reason;
109 enum pbc_status pbc_status;
110 u8 peer_addr[ETH_ALEN];
111 };
112
113 struct hostapd_neighbor_entry {
114 struct dl_list list;
115 u8 bssid[ETH_ALEN];
116 struct wpa_ssid_value ssid;
117 struct wpabuf *nr;
118 struct wpabuf *lci;
119 struct wpabuf *civic;
120 /* LCI update time */
121 struct os_time lci_date;
122 int stationary;
123 };
124
125 /**
126 * struct hostapd_data - hostapd per-BSS data structure
127 */
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;
136
137 u8 own_addr[ETH_ALEN];
138
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];
144
145 /*
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
148 * 1.
149 */
150 #define AID_WORDS ((2008 + 31) / 32)
151 u32 sta_aid[AID_WORDS];
152
153 const struct wpa_driver_ops *driver;
154 void *drv_priv;
155
156 void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
157 struct sta_info *sta, int reassoc);
158
159 void *msg_ctx; /* ctx for wpa_msg() calls */
160 void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
161
162 struct radius_client_data *radius;
163 u64 acct_session_id;
164 struct radius_das_data *radius_das;
165
166 struct iapp_data *iapp;
167
168 struct hostapd_cached_radius_acl *acl_cache;
169 struct hostapd_acl_query_data *acl_queries;
170
171 struct wpa_authenticator *wpa_auth;
172 struct eapol_authenticator *eapol_auth;
173
174 struct rsn_preauth_interface *preauth_iface;
175 struct os_reltime michael_mic_failure;
176 int michael_mic_failures;
177 int tkip_countermeasures;
178
179 int ctrl_sock;
180 struct dl_list ctrl_dst;
181
182 void *ssl_ctx;
183 void *eap_sim_db_priv;
184 struct radius_server_data *radius_srv;
185 struct dl_list erp_keys; /* struct eap_server_erp_key */
186
187 int parameter_set_count;
188
189 /* Time Advertisement */
190 u8 time_update_counter;
191 struct wpabuf *time_adv;
192
193 #ifdef CONFIG_FULL_DYNAMIC_VLAN
194 struct full_dynamic_vlan *full_dynamic_vlan;
195 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
196
197 struct l2_packet_data *l2;
198
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 */
208
209 struct wps_context *wps;
210
211 int beacon_set_done;
212 struct wpabuf *wps_beacon_ie;
213 struct wpabuf *wps_probe_resp_ie;
214 #ifdef CONFIG_WPS
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;
219
220 struct wps_stat wps_stats;
221 #endif /* CONFIG_WPS */
222
223 struct hostapd_probereq_cb *probereq_cb;
224 size_t num_probereq_cb;
225
226 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
227 int freq);
228 void *public_action_cb_ctx;
229 void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
230 int freq);
231 void *public_action_cb2_ctx;
232
233 int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
234 int freq);
235 void *vendor_action_cb_ctx;
236
237 void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
238 const u8 *uuid_e);
239 void *wps_reg_success_cb_ctx;
240
241 void (*wps_event_cb)(void *ctx, enum wps_event event,
242 union wps_event_data *data);
243 void *wps_event_cb_ctx;
244
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;
248
249 void (*setup_complete_cb)(void *ctx);
250 void *setup_complete_cb_ctx;
251
252 void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
253 const u8 *p2p_dev_addr, const u8 *psk,
254 size_t psk_len);
255 void *new_psk_cb_ctx;
256
257 /* channel switch parameters */
258 struct hostapd_freq_params cs_freq_params;
259 u8 cs_count;
260 int cs_block_tx;
261 unsigned int cs_c_off_beacon;
262 unsigned int cs_c_off_proberesp;
263 int csa_in_progress;
264 unsigned int cs_c_off_ecsa_beacon;
265 unsigned int cs_c_off_ecsa_proberesp;
266
267 #ifdef CONFIG_P2P
268 struct p2p_data *p2p;
269 struct p2p_group *p2p_group;
270 struct wpabuf *p2p_beacon_ie;
271 struct wpabuf *p2p_probe_resp_ie;
272
273 /* Number of non-P2P association stations */
274 int num_sta_no_p2p;
275
276 /* Periodic NoA (used only when no non-P2P clients in the group) */
277 int noa_enabled;
278 int noa_start;
279 int noa_duration;
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 */
285 #ifdef CONFIG_MESH
286 int num_plinks;
287 int max_plinks;
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 */
294
295 #ifdef CONFIG_SQLITE
296 struct hostapd_eap_user tmp_eap_user;
297 #endif /* CONFIG_SQLITE */
298
299 #ifdef CONFIG_SAE
300 /** Key used for generating SAE anti-clogging tokens */
301 u8 sae_token_key[8];
302 struct os_reltime last_sae_token_key_update;
303 int dot11RSNASAERetransPeriod; /* msec */
304 #endif /* CONFIG_SAE */
305
306 #ifdef CONFIG_TESTING_OPTIONS
307 unsigned int ext_mgmt_frame_handling:1;
308 unsigned int ext_eapol_frame_io:1;
309
310 struct l2_packet_data *l2_test;
311
312 enum wpa_alg last_gtk_alg;
313 int last_gtk_key_idx;
314 u8 last_gtk[WPA_GTK_MAX_LEN];
315 size_t last_gtk_len;
316
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 */
324
325 #ifdef CONFIG_MBO
326 unsigned int mbo_assoc_disallow;
327 /**
328 * enable_oce - Enable OCE if it is enabled by user and device also
329 * supports OCE.
330 */
331 u8 enable_oce;
332 #endif /* CONFIG_MBO */
333
334 struct dl_list nr_db;
335
336 u8 beacon_req_token;
337 u8 lci_req_token;
338 u8 range_req_token;
339 unsigned int lci_req_active:1;
340 unsigned int range_req_active:1;
341
342 int dhcp_sock; /* UDP socket used with the DHCP server */
343
344 #ifdef CONFIG_DPP
345 int dpp_init_done;
346 struct dpp_authentication *dpp_auth;
347 u8 dpp_allowed_roles;
348 int dpp_qr_mutual;
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;
354 char *dpp_pkex_code;
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 */
372 };
373
374
375 struct hostapd_sta_info {
376 struct dl_list list;
377 u8 addr[ETH_ALEN];
378 struct os_reltime last_seen;
379 int ssi_signal;
380 #ifdef CONFIG_TAXONOMY
381 struct wpabuf *probe_ie_taxonomy;
382 #endif /* CONFIG_TAXONOMY */
383 };
384
385 /**
386 * struct hostapd_iface - hostapd per-interface data structure
387 */
388 struct hostapd_iface {
389 struct hapd_interfaces *interfaces;
390 void *owner;
391 char *config_fname;
392 struct hostapd_config *conf;
393 char phy[16]; /* Name of the PHY (radio) */
394
395 enum hostapd_iface_state {
396 HAPD_IFACE_UNINITIALIZED,
397 HAPD_IFACE_DISABLED,
398 HAPD_IFACE_COUNTRY_UPDATE,
399 HAPD_IFACE_ACS,
400 HAPD_IFACE_HT_SCAN,
401 HAPD_IFACE_DFS,
402 HAPD_IFACE_ENABLED
403 } state;
404
405 #ifdef CONFIG_MESH
406 struct mesh_conf *mconf;
407 #endif /* CONFIG_MESH */
408
409 size_t num_bss;
410 struct hostapd_data **bss;
411
412 unsigned int wait_channel_update:1;
413 unsigned int cac_started:1;
414 #ifdef CONFIG_FST
415 struct fst_iface *fst;
416 const struct wpabuf *fst_ies;
417 #endif /* CONFIG_FST */
418
419 /*
420 * When set, indicates that the driver will handle the AP
421 * teardown: delete global keys, station keys, and stations.
422 */
423 unsigned int driver_ap_teardown:1;
424
425 /*
426 * When set, indicates that this interface is part of list of
427 * interfaces that need to be started together (synchronously).
428 */
429 unsigned int need_to_start_in_sync:1;
430
431 /* Ready to start but waiting for other interfaces to become ready. */
432 unsigned int ready_to_start_in_sync:1;
433
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];
437
438 u64 drv_flags;
439
440 /* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */
441 unsigned int smps_modes;
442
443 /*
444 * A bitmap of supported protocols for probe response offload. See
445 * struct wpa_driver_capa in driver.h
446 */
447 unsigned int probe_resp_offloads;
448
449 /* extended capabilities supported by the driver */
450 const u8 *extended_capa, *extended_capa_mask;
451 unsigned int extended_capa_len;
452
453 unsigned int drv_max_acl_mac_addrs;
454
455 struct hostapd_hw_modes *hw_features;
456 int num_hw_features;
457 struct hostapd_hw_modes *current_mode;
458 /* Rates that are currently used (i.e., filtered copy of
459 * current_mode->channels */
460 int num_rates;
461 struct hostapd_rate_data *current_rates;
462 int *basic_rates;
463 int freq;
464
465 u16 hw_flags;
466
467 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
468 * in 802.11g BSS) */
469 int num_sta_non_erp;
470
471 /* Number of associated stations that do not support Short Slot Time */
472 int num_sta_no_short_slot_time;
473
474 /* Number of associated stations that do not support Short Preamble */
475 int num_sta_no_short_preamble;
476
477 int olbc; /* Overlapping Legacy BSS Condition */
478
479 /* Number of HT associated stations that do not support greenfield */
480 int num_sta_ht_no_gf;
481
482 /* Number of associated non-HT stations */
483 int num_sta_no_ht;
484
485 /* Number of HT associated stations 20 MHz */
486 int num_sta_ht_20mhz;
487
488 /* Number of HT40 intolerant stations */
489 int num_sta_ht40_intolerant;
490
491 /* Overlapping BSS information */
492 int olbc_ht;
493
494 u16 ht_op_mode;
495
496 /* surveying helpers */
497
498 /* number of channels surveyed */
499 unsigned int chans_surveyed;
500
501 /* lowest observed noise floor in dBm */
502 s8 lowest_nf;
503
504 /* channel utilization calculation */
505 u64 last_channel_time;
506 u64 last_channel_time_busy;
507 u8 channel_utilization;
508
509 unsigned int chan_util_samples_sum;
510 unsigned int chan_util_num_sample_periods;
511 unsigned int chan_util_average;
512
513 /* eCSA IE will be added only if operating class is specified */
514 u8 cs_oper_class;
515
516 unsigned int dfs_cac_ms;
517 struct os_reltime dfs_cac_start;
518
519 /* Latched with the actual secondary channel information and will be
520 * used while juggling between HT20 and HT40 modes. */
521 int secondary_ch;
522
523 #ifdef CONFIG_ACS
524 unsigned int acs_num_completed_scans;
525 #endif /* CONFIG_ACS */
526
527 void (*scan_cb)(struct hostapd_iface *iface);
528 int num_ht40_scan_tries;
529
530 struct dl_list sta_seen; /* struct hostapd_sta_info */
531 unsigned int num_sta_seen;
532
533 u8 dfs_domain;
534 };
535
536 /* hostapd.c */
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,
556 int reassoc);
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);
570 void
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);
576
577 /* utils.c */
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,
582 int ssi_signal),
583 void *ctx);
584 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
585
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,
597 int ssi_signal);
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);
605
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);
609
610 struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces,
611 const char *ifname);
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);
615
616 #ifdef CONFIG_FST
617 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
618 struct fst_wpa_obj *iface_obj);
619 #endif /* CONFIG_FST */
620
621 #endif /* HOSTAPD_H */