]>
Commit | Line | Data |
---|---|---|
6fc6879b JM |
1 | /* |
2 | * hostapd / Initialization and configuration | |
5ae6449c | 3 | * Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi> |
6fc6879b | 4 | * |
0f3d578e JM |
5 | * This software may be distributed under the terms of the BSD license. |
6 | * See README for more details. | |
6fc6879b JM |
7 | */ |
8 | ||
9 | #ifndef HOSTAPD_H | |
10 | #define HOSTAPD_H | |
11 | ||
45cefa0b | 12 | #include "common/defs.h" |
ee431d77 | 13 | #include "ap_config.h" |
13daed58 | 14 | #include "drivers/driver.h" |
45cefa0b | 15 | |
6fc6879b JM |
16 | struct wpa_ctrl_dst; |
17 | struct radius_server_data; | |
f620268f | 18 | struct upnp_wps_device_sm; |
bf65bc63 | 19 | struct hostapd_data; |
45cefa0b | 20 | struct sta_info; |
2ce86d9d | 21 | struct ieee80211_ht_capabilities; |
6fc6879b | 22 | struct full_dynamic_vlan; |
a0dee797 AGS |
23 | enum wps_event; |
24 | union wps_event_data; | |
6fc6879b | 25 | |
3776ac73 JM |
26 | struct hostapd_iface; |
27 | ||
07bcdbb1 | 28 | struct hapd_interfaces { |
3776ac73 JM |
29 | int (*reload_config)(struct hostapd_iface *iface); |
30 | struct hostapd_config * (*config_read_cb)(const char *config_fname); | |
31 | int (*ctrl_iface_init)(struct hostapd_data *hapd); | |
32 | void (*ctrl_iface_deinit)(struct hostapd_data *hapd); | |
33 | int (*for_each_interface)(struct hapd_interfaces *interfaces, | |
34 | int (*cb)(struct hostapd_iface *iface, | |
35 | void *ctx), void *ctx); | |
75545652 | 36 | int (*driver_init)(struct hostapd_iface *iface); |
3776ac73 | 37 | |
07bcdbb1 | 38 | size_t count; |
c90fd485 SP |
39 | int global_ctrl_sock; |
40 | char *global_iface_path; | |
41 | char *global_iface_name; | |
461e3ebe | 42 | #ifndef CONFIG_NATIVE_WINDOWS |
187f87f0 | 43 | gid_t ctrl_iface_group; |
461e3ebe | 44 | #endif /* CONFIG_NATIVE_WINDOWS */ |
07bcdbb1 | 45 | struct hostapd_iface **iface; |
2b6623ab JM |
46 | |
47 | size_t terminate_on_error; | |
07bcdbb1 JM |
48 | }; |
49 | ||
245e026e MK |
50 | enum hostapd_chan_status { |
51 | HOSTAPD_CHAN_VALID = 0, /* channel is ready */ | |
52 | HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */ | |
53 | HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */ | |
54 | }; | |
07bcdbb1 | 55 | |
fa16028d | 56 | struct hostapd_probereq_cb { |
04a85e44 | 57 | int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid, |
baf513d6 | 58 | const u8 *ie, size_t ie_len, int ssi_signal); |
fa16028d JM |
59 | void *ctx; |
60 | }; | |
61 | ||
fb7842aa JM |
62 | #define HOSTAPD_RATE_BASIC 0x00000001 |
63 | ||
64 | struct hostapd_rate_data { | |
65 | int rate; /* rate in 100 kbps */ | |
66 | int flags; /* HOSTAPD_RATE_ flags */ | |
67 | }; | |
68 | ||
2a8b7416 JM |
69 | struct hostapd_frame_info { |
70 | u32 channel; | |
71 | u32 datarate; | |
baf513d6 | 72 | int ssi_signal; /* dBm */ |
2a8b7416 JM |
73 | }; |
74 | ||
61b6520e JM |
75 | enum wps_status { |
76 | WPS_STATUS_SUCCESS = 1, | |
77 | WPS_STATUS_FAILURE | |
78 | }; | |
79 | ||
ae23935e JM |
80 | enum pbc_status { |
81 | WPS_PBC_STATUS_DISABLE, | |
82 | WPS_PBC_STATUS_ACTIVE, | |
83 | WPS_PBC_STATUS_TIMEOUT, | |
84 | WPS_PBC_STATUS_OVERLAP | |
85 | }; | |
86 | ||
61b6520e JM |
87 | struct wps_stat { |
88 | enum wps_status status; | |
89 | enum wps_error_indication failure_reason; | |
ae23935e | 90 | enum pbc_status pbc_status; |
e96872a4 | 91 | u8 peer_addr[ETH_ALEN]; |
61b6520e JM |
92 | }; |
93 | ||
fb7842aa | 94 | |
6fc6879b JM |
95 | /** |
96 | * struct hostapd_data - hostapd per-BSS data structure | |
97 | */ | |
98 | struct hostapd_data { | |
99 | struct hostapd_iface *iface; | |
100 | struct hostapd_config *iconf; | |
101 | struct hostapd_bss_config *conf; | |
6023a788 | 102 | int interface_added; /* virtual interface added for this BSS */ |
36501a22 | 103 | unsigned int started:1; |
6fc6879b JM |
104 | |
105 | u8 own_addr[ETH_ALEN]; | |
106 | ||
107 | int num_sta; /* number of entries in sta_list */ | |
108 | struct sta_info *sta_list; /* STA info list head */ | |
2991469c JM |
109 | #define STA_HASH_SIZE 256 |
110 | #define STA_HASH(sta) (sta[5]) | |
6fc6879b JM |
111 | struct sta_info *sta_hash[STA_HASH_SIZE]; |
112 | ||
2991469c JM |
113 | /* |
114 | * Bitfield for indicating which AIDs are allocated. Only AID values | |
115 | * 1-2007 are used and as such, the bit at index 0 corresponds to AID | |
116 | * 1. | |
6fc6879b | 117 | */ |
2991469c JM |
118 | #define AID_WORDS ((2008 + 31) / 32) |
119 | u32 sta_aid[AID_WORDS]; | |
6fc6879b | 120 | |
c5121837 | 121 | const struct wpa_driver_ops *driver; |
6fc6879b JM |
122 | void *drv_priv; |
123 | ||
d24df7c3 JM |
124 | void (*new_assoc_sta_cb)(struct hostapd_data *hapd, |
125 | struct sta_info *sta, int reassoc); | |
126 | ||
4f760fcc | 127 | void *msg_ctx; /* ctx for wpa_msg() calls */ |
8a5e75f6 | 128 | void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */ |
4f760fcc | 129 | |
6fc6879b | 130 | struct radius_client_data *radius; |
6fc6879b | 131 | u32 acct_session_id_hi, acct_session_id_lo; |
b031338c | 132 | struct radius_das_data *radius_das; |
6fc6879b JM |
133 | |
134 | struct iapp_data *iapp; | |
135 | ||
6fc6879b JM |
136 | struct hostapd_cached_radius_acl *acl_cache; |
137 | struct hostapd_acl_query_data *acl_queries; | |
138 | ||
139 | struct wpa_authenticator *wpa_auth; | |
140 | struct eapol_authenticator *eapol_auth; | |
141 | ||
142 | struct rsn_preauth_interface *preauth_iface; | |
7ffe7d22 | 143 | struct os_reltime michael_mic_failure; |
6fc6879b JM |
144 | int michael_mic_failures; |
145 | int tkip_countermeasures; | |
146 | ||
147 | int ctrl_sock; | |
148 | struct wpa_ctrl_dst *ctrl_dst; | |
149 | ||
150 | void *ssl_ctx; | |
151 | void *eap_sim_db_priv; | |
152 | struct radius_server_data *radius_srv; | |
153 | ||
154 | int parameter_set_count; | |
155 | ||
39b97072 JM |
156 | /* Time Advertisement */ |
157 | u8 time_update_counter; | |
158 | struct wpabuf *time_adv; | |
159 | ||
6fc6879b JM |
160 | #ifdef CONFIG_FULL_DYNAMIC_VLAN |
161 | struct full_dynamic_vlan *full_dynamic_vlan; | |
162 | #endif /* CONFIG_FULL_DYNAMIC_VLAN */ | |
163 | ||
164 | struct l2_packet_data *l2; | |
ad08c363 JM |
165 | struct wps_context *wps; |
166 | ||
bc45d427 | 167 | int beacon_set_done; |
14f79386 JM |
168 | struct wpabuf *wps_beacon_ie; |
169 | struct wpabuf *wps_probe_resp_ie; | |
84312359 | 170 | #ifdef CONFIG_WPS |
3b2cf800 | 171 | unsigned int ap_pin_failures; |
32cdcf15 | 172 | unsigned int ap_pin_failures_consecutive; |
f620268f | 173 | struct upnp_wps_device_sm *wps_upnp; |
94481410 | 174 | unsigned int ap_pin_lockout_time; |
61b6520e JM |
175 | |
176 | struct wps_stat wps_stats; | |
ad08c363 | 177 | #endif /* CONFIG_WPS */ |
fa16028d JM |
178 | |
179 | struct hostapd_probereq_cb *probereq_cb; | |
180 | size_t num_probereq_cb; | |
195420b8 | 181 | |
c706d5aa JM |
182 | void (*public_action_cb)(void *ctx, const u8 *buf, size_t len, |
183 | int freq); | |
184 | void *public_action_cb_ctx; | |
2d9ffe1e JM |
185 | void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len, |
186 | int freq); | |
187 | void *public_action_cb2_ctx; | |
c706d5aa | 188 | |
e44f8bf2 JM |
189 | int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len, |
190 | int freq); | |
191 | void *vendor_action_cb_ctx; | |
192 | ||
195420b8 JM |
193 | void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr, |
194 | const u8 *uuid_e); | |
195 | void *wps_reg_success_cb_ctx; | |
c2af2afb | 196 | |
a0dee797 AGS |
197 | void (*wps_event_cb)(void *ctx, enum wps_event event, |
198 | union wps_event_data *data); | |
199 | void *wps_event_cb_ctx; | |
200 | ||
0661eed2 | 201 | void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr, |
fbdcfd57 | 202 | int authorized, const u8 *p2p_dev_addr); |
0661eed2 JB |
203 | void *sta_authorized_cb_ctx; |
204 | ||
c76e5d7f JB |
205 | void (*setup_complete_cb)(void *ctx); |
206 | void *setup_complete_cb_ctx; | |
207 | ||
01a57fe4 JM |
208 | void (*new_psk_cb)(void *ctx, const u8 *mac_addr, |
209 | const u8 *p2p_dev_addr, const u8 *psk, | |
210 | size_t psk_len); | |
211 | void *new_psk_cb_ctx; | |
212 | ||
6782b684 MK |
213 | /* channel switch parameters */ |
214 | struct hostapd_freq_params cs_freq_params; | |
215 | u8 cs_count; | |
216 | int cs_block_tx; | |
217 | unsigned int cs_c_off_beacon; | |
218 | unsigned int cs_c_off_proberesp; | |
219 | int csa_in_progress; | |
220 | ||
ec8f36af KP |
221 | /* BSS Load */ |
222 | unsigned int bss_load_update_timeout; | |
223 | ||
c2af2afb | 224 | #ifdef CONFIG_P2P |
e44f8bf2 JM |
225 | struct p2p_data *p2p; |
226 | struct p2p_group *p2p_group; | |
c2af2afb JM |
227 | struct wpabuf *p2p_beacon_ie; |
228 | struct wpabuf *p2p_probe_resp_ie; | |
aefb53bd JM |
229 | |
230 | /* Number of non-P2P association stations */ | |
231 | int num_sta_no_p2p; | |
232 | ||
233 | /* Periodic NoA (used only when no non-P2P clients in the group) */ | |
234 | int noa_enabled; | |
235 | int noa_start; | |
236 | int noa_duration; | |
c2af2afb | 237 | #endif /* CONFIG_P2P */ |
dca30c3f JK |
238 | #ifdef CONFIG_INTERWORKING |
239 | size_t gas_frag_limit; | |
240 | #endif /* CONFIG_INTERWORKING */ | |
ee431d77 JM |
241 | |
242 | #ifdef CONFIG_SQLITE | |
243 | struct hostapd_eap_user tmp_eap_user; | |
244 | #endif /* CONFIG_SQLITE */ | |
d136c376 JM |
245 | |
246 | #ifdef CONFIG_SAE | |
247 | /** Key used for generating SAE anti-clogging tokens */ | |
248 | u8 sae_token_key[8]; | |
fe52c210 | 249 | struct os_reltime last_sae_token_key_update; |
d136c376 | 250 | #endif /* CONFIG_SAE */ |
93827f45 JM |
251 | |
252 | #ifdef CONFIG_TESTING_OPTIONS | |
9d4ff04a JM |
253 | unsigned int ext_mgmt_frame_handling:1; |
254 | unsigned int ext_eapol_frame_io:1; | |
4a6cc862 JM |
255 | |
256 | struct l2_packet_data *l2_test; | |
93827f45 | 257 | #endif /* CONFIG_TESTING_OPTIONS */ |
6fc6879b JM |
258 | }; |
259 | ||
260 | ||
6fc6879b JM |
261 | /** |
262 | * struct hostapd_iface - hostapd per-interface data structure | |
263 | */ | |
264 | struct hostapd_iface { | |
9969e5a4 | 265 | struct hapd_interfaces *interfaces; |
0f2b2c19 | 266 | void *owner; |
6fc6879b JM |
267 | char *config_fname; |
268 | struct hostapd_config *conf; | |
5afaa067 | 269 | char phy[16]; /* Name of the PHY (radio) */ |
6fc6879b | 270 | |
e1c5faf0 JM |
271 | enum hostapd_iface_state { |
272 | HAPD_IFACE_UNINITIALIZED, | |
273 | HAPD_IFACE_DISABLED, | |
274 | HAPD_IFACE_COUNTRY_UPDATE, | |
275 | HAPD_IFACE_ACS, | |
276 | HAPD_IFACE_HT_SCAN, | |
277 | HAPD_IFACE_DFS, | |
278 | HAPD_IFACE_ENABLED | |
279 | } state; | |
280 | ||
6fc6879b JM |
281 | size_t num_bss; |
282 | struct hostapd_data **bss; | |
283 | ||
f0793bf1 | 284 | unsigned int wait_channel_update:1; |
dc036d9e | 285 | unsigned int cac_started:1; |
f0793bf1 | 286 | |
354c903f MB |
287 | /* |
288 | * When set, indicates that the driver will handle the AP | |
289 | * teardown: delete global keys, station keys, and stations. | |
290 | */ | |
291 | unsigned int driver_ap_teardown:1; | |
292 | ||
6fc6879b JM |
293 | int num_ap; /* number of entries in ap_list */ |
294 | struct ap_info *ap_list; /* AP info list head */ | |
295 | struct ap_info *ap_hash[STA_HASH_SIZE]; | |
6fc6879b | 296 | |
2fee890a | 297 | unsigned int drv_flags; |
4f73d88a | 298 | |
04ee647d EP |
299 | /* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */ |
300 | unsigned int smps_modes; | |
301 | ||
4f73d88a AN |
302 | /* |
303 | * A bitmap of supported protocols for probe response offload. See | |
304 | * struct wpa_driver_capa in driver.h | |
305 | */ | |
306 | unsigned int probe_resp_offloads; | |
307 | ||
8cd6b7bc JB |
308 | /* extended capabilities supported by the driver */ |
309 | const u8 *extended_capa, *extended_capa_mask; | |
310 | unsigned int extended_capa_len; | |
311 | ||
3cb953e4 JM |
312 | unsigned int drv_max_acl_mac_addrs; |
313 | ||
6fc6879b JM |
314 | struct hostapd_hw_modes *hw_features; |
315 | int num_hw_features; | |
316 | struct hostapd_hw_modes *current_mode; | |
317 | /* Rates that are currently used (i.e., filtered copy of | |
318 | * current_mode->channels */ | |
319 | int num_rates; | |
320 | struct hostapd_rate_data *current_rates; | |
e5693c47 | 321 | int *basic_rates; |
c706d5aa | 322 | int freq; |
6fc6879b JM |
323 | |
324 | u16 hw_flags; | |
325 | ||
326 | /* Number of associated Non-ERP stations (i.e., stations using 802.11b | |
327 | * in 802.11g BSS) */ | |
328 | int num_sta_non_erp; | |
329 | ||
330 | /* Number of associated stations that do not support Short Slot Time */ | |
331 | int num_sta_no_short_slot_time; | |
332 | ||
333 | /* Number of associated stations that do not support Short Preamble */ | |
334 | int num_sta_no_short_preamble; | |
335 | ||
336 | int olbc; /* Overlapping Legacy BSS Condition */ | |
337 | ||
de9289c8 JM |
338 | /* Number of HT associated stations that do not support greenfield */ |
339 | int num_sta_ht_no_gf; | |
340 | ||
341 | /* Number of associated non-HT stations */ | |
342 | int num_sta_no_ht; | |
343 | ||
344 | /* Number of HT associated stations 20 MHz */ | |
345 | int num_sta_ht_20mhz; | |
346 | ||
9c47f6a2 PX |
347 | /* Number of HT40 intolerant stations */ |
348 | int num_sta_ht40_intolerant; | |
349 | ||
de9289c8 JM |
350 | /* Overlapping BSS information */ |
351 | int olbc_ht; | |
352 | ||
edd360e1 | 353 | u16 ht_op_mode; |
0185007c MK |
354 | |
355 | /* surveying helpers */ | |
356 | ||
357 | /* number of channels surveyed */ | |
358 | unsigned int chans_surveyed; | |
359 | ||
360 | /* lowest observed noise floor in dBm */ | |
361 | s8 lowest_nf; | |
362 | ||
ec8f36af KP |
363 | /* channel utilization calculation */ |
364 | u64 last_channel_time; | |
365 | u64 last_channel_time_busy; | |
366 | u8 channel_utilization; | |
367 | ||
bbbacbf2 JD |
368 | unsigned int dfs_cac_ms; |
369 | struct os_reltime dfs_cac_start; | |
370 | ||
9c47f6a2 PX |
371 | /* Latched with the actual secondary channel information and will be |
372 | * used while juggling between HT20 and HT40 modes. */ | |
373 | int secondary_ch; | |
374 | ||
50f4f2a0 MK |
375 | #ifdef CONFIG_ACS |
376 | unsigned int acs_num_completed_scans; | |
377 | #endif /* CONFIG_ACS */ | |
378 | ||
ad1e68e6 | 379 | void (*scan_cb)(struct hostapd_iface *iface); |
5f0bca77 | 380 | int num_ht40_scan_tries; |
6fc6879b JM |
381 | }; |
382 | ||
a4f21109 | 383 | /* hostapd.c */ |
07bcdbb1 JM |
384 | int hostapd_for_each_interface(struct hapd_interfaces *interfaces, |
385 | int (*cb)(struct hostapd_iface *iface, | |
386 | void *ctx), void *ctx); | |
ad08c363 | 387 | int hostapd_reload_config(struct hostapd_iface *iface); |
b6a7859d JM |
388 | struct hostapd_data * |
389 | hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, | |
390 | struct hostapd_config *conf, | |
391 | struct hostapd_bss_config *bss); | |
5c333467 | 392 | int hostapd_setup_interface(struct hostapd_iface *iface); |
ad1e68e6 | 393 | int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err); |
5c333467 | 394 | void hostapd_interface_deinit(struct hostapd_iface *iface); |
f7c47833 | 395 | void hostapd_interface_free(struct hostapd_iface *iface); |
66936c6a KP |
396 | struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces, |
397 | const char *config_file); | |
a1fb5692 KP |
398 | struct hostapd_iface * |
399 | hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy, | |
400 | const char *config_fname, int debug); | |
a4f21109 JM |
401 | void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, |
402 | int reassoc); | |
75545652 SP |
403 | void hostapd_interface_deinit_free(struct hostapd_iface *iface); |
404 | int hostapd_enable_iface(struct hostapd_iface *hapd_iface); | |
405 | int hostapd_reload_iface(struct hostapd_iface *hapd_iface); | |
406 | int hostapd_disable_iface(struct hostapd_iface *hapd_iface); | |
06bb8c62 SP |
407 | int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf); |
408 | int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf); | |
795baf77 | 409 | void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator); |
e1c5faf0 | 410 | void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s); |
5ae6449c | 411 | const char * hostapd_state_text(enum hostapd_iface_state s); |
bf281c12 AO |
412 | int hostapd_switch_channel(struct hostapd_data *hapd, |
413 | struct csa_settings *settings); | |
5841958f MK |
414 | void |
415 | hostapd_switch_channel_fallback(struct hostapd_iface *iface, | |
416 | const struct hostapd_freq_params *freq_params); | |
bf281c12 | 417 | void hostapd_cleanup_cs_params(struct hostapd_data *hapd); |
5c333467 | 418 | |
a4f21109 | 419 | /* utils.c */ |
fa16028d | 420 | int hostapd_register_probereq_cb(struct hostapd_data *hapd, |
cd7d80f3 | 421 | int (*cb)(void *ctx, const u8 *sa, |
04a85e44 | 422 | const u8 *da, const u8 *bssid, |
baf513d6 JB |
423 | const u8 *ie, size_t ie_len, |
424 | int ssi_signal), | |
fa16028d | 425 | void *ctx); |
0aef3ec8 | 426 | void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr); |
fa16028d | 427 | |
1d041bec JM |
428 | /* drv_callbacks.c (TODO: move to somewhere else?) */ |
429 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, | |
39b08b5f | 430 | const u8 *ie, size_t ielen, int reassoc); |
1d041bec | 431 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr); |
0d7e5a3a | 432 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr); |
3140803b RM |
433 | void hostapd_event_connect_failed_reason(struct hostapd_data *hapd, |
434 | const u8 *addr, int reason_code); | |
04a85e44 | 435 | int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, |
baf513d6 JB |
436 | const u8 *bssid, const u8 *ie, size_t ie_len, |
437 | int ssi_signal); | |
1b487b8b | 438 | void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, |
8d1fdde7 | 439 | int offset, int width, int cf1, int cf2); |
1d041bec | 440 | |
ee431d77 JM |
441 | const struct hostapd_eap_user * |
442 | hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity, | |
443 | size_t identity_len, int phase2); | |
444 | ||
6fc6879b | 445 | #endif /* HOSTAPD_H */ |