2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2013, 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 "ap_config.h"
14 #include "drivers/driver.h"
17 struct radius_server_data;
18 struct upnp_wps_device_sm;
21 struct ieee80211_ht_capabilities;
22 struct full_dynamic_vlan;
27 struct hostapd_dynamic_iface;
29 struct hapd_interfaces {
30 int (*reload_config)(struct hostapd_iface *iface);
31 struct hostapd_config * (*config_read_cb)(const char *config_fname);
32 int (*ctrl_iface_init)(struct hostapd_data *hapd);
33 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
34 int (*for_each_interface)(struct hapd_interfaces *interfaces,
35 int (*cb)(struct hostapd_iface *iface,
36 void *ctx), void *ctx);
37 int (*driver_init)(struct hostapd_iface *iface);
42 char *global_iface_path;
43 char *global_iface_name;
44 #ifndef CONFIG_NATIVE_WINDOWS
45 gid_t ctrl_iface_group;
46 #endif /* CONFIG_NATIVE_WINDOWS */
47 struct hostapd_iface **iface;
48 struct hostapd_dynamic_iface **dynamic_iface;
50 size_t terminate_on_error;
53 enum hostapd_chan_status {
54 HOSTAPD_CHAN_VALID = 0, /* channel is ready */
55 HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */
56 HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */
59 struct hostapd_probereq_cb {
60 int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
61 const u8 *ie, size_t ie_len, int ssi_signal);
65 #define HOSTAPD_RATE_BASIC 0x00000001
67 struct hostapd_rate_data {
68 int rate; /* rate in 100 kbps */
69 int flags; /* HOSTAPD_RATE_ flags */
72 struct hostapd_frame_info {
75 int ssi_signal; /* dBm */
79 WPS_STATUS_SUCCESS = 1,
84 WPS_PBC_STATUS_DISABLE,
85 WPS_PBC_STATUS_ACTIVE,
86 WPS_PBC_STATUS_TIMEOUT,
87 WPS_PBC_STATUS_OVERLAP
91 enum wps_status status;
92 enum wps_error_indication failure_reason;
93 enum pbc_status pbc_status;
94 u8 peer_addr[ETH_ALEN];
99 * struct hostapd_data - hostapd per-BSS data structure
101 struct hostapd_data {
102 struct hostapd_iface *iface;
103 struct hostapd_config *iconf;
104 struct hostapd_bss_config *conf;
105 int interface_added; /* virtual interface added for this BSS */
106 unsigned int started:1;
108 u8 own_addr[ETH_ALEN];
110 int num_sta; /* number of entries in sta_list */
111 struct sta_info *sta_list; /* STA info list head */
112 #define STA_HASH_SIZE 256
113 #define STA_HASH(sta) (sta[5])
114 struct sta_info *sta_hash[STA_HASH_SIZE];
117 * Bitfield for indicating which AIDs are allocated. Only AID values
118 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
121 #define AID_WORDS ((2008 + 31) / 32)
122 u32 sta_aid[AID_WORDS];
124 const struct wpa_driver_ops *driver;
127 void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
128 struct sta_info *sta, int reassoc);
130 void *msg_ctx; /* ctx for wpa_msg() calls */
131 void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
133 struct radius_client_data *radius;
134 u32 acct_session_id_hi, acct_session_id_lo;
135 struct radius_das_data *radius_das;
137 struct iapp_data *iapp;
139 struct hostapd_cached_radius_acl *acl_cache;
140 struct hostapd_acl_query_data *acl_queries;
142 struct wpa_authenticator *wpa_auth;
143 struct eapol_authenticator *eapol_auth;
145 struct rsn_preauth_interface *preauth_iface;
146 struct os_reltime michael_mic_failure;
147 int michael_mic_failures;
148 int tkip_countermeasures;
151 struct wpa_ctrl_dst *ctrl_dst;
154 void *eap_sim_db_priv;
155 struct radius_server_data *radius_srv;
157 int parameter_set_count;
159 /* Time Advertisement */
160 u8 time_update_counter;
161 struct wpabuf *time_adv;
163 #ifdef CONFIG_FULL_DYNAMIC_VLAN
164 struct full_dynamic_vlan *full_dynamic_vlan;
165 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
167 struct l2_packet_data *l2;
168 struct wps_context *wps;
171 struct wpabuf *wps_beacon_ie;
172 struct wpabuf *wps_probe_resp_ie;
174 unsigned int ap_pin_failures;
175 unsigned int ap_pin_failures_consecutive;
176 struct upnp_wps_device_sm *wps_upnp;
177 unsigned int ap_pin_lockout_time;
179 struct wps_stat wps_stats;
180 #endif /* CONFIG_WPS */
182 struct hostapd_probereq_cb *probereq_cb;
183 size_t num_probereq_cb;
185 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
187 void *public_action_cb_ctx;
188 void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
190 void *public_action_cb2_ctx;
192 int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
194 void *vendor_action_cb_ctx;
196 void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
198 void *wps_reg_success_cb_ctx;
200 void (*wps_event_cb)(void *ctx, enum wps_event event,
201 union wps_event_data *data);
202 void *wps_event_cb_ctx;
204 void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
205 int authorized, const u8 *p2p_dev_addr);
206 void *sta_authorized_cb_ctx;
208 void (*setup_complete_cb)(void *ctx);
209 void *setup_complete_cb_ctx;
211 void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
212 const u8 *p2p_dev_addr, const u8 *psk,
214 void *new_psk_cb_ctx;
217 struct p2p_data *p2p;
218 struct p2p_group *p2p_group;
219 struct wpabuf *p2p_beacon_ie;
220 struct wpabuf *p2p_probe_resp_ie;
222 /* Number of non-P2P association stations */
225 /* Periodic NoA (used only when no non-P2P clients in the group) */
229 #endif /* CONFIG_P2P */
230 #ifdef CONFIG_INTERWORKING
231 size_t gas_frag_limit;
232 #endif /* CONFIG_INTERWORKING */
235 struct hostapd_eap_user tmp_eap_user;
236 #endif /* CONFIG_SQLITE */
239 /** Key used for generating SAE anti-clogging tokens */
241 struct os_reltime last_sae_token_key_update;
242 #endif /* CONFIG_SAE */
244 #ifdef CONFIG_TESTING_OPTIONS
245 int ext_mgmt_frame_handling;
246 #endif /* CONFIG_TESTING_OPTIONS */
251 * struct hostapd_iface - hostapd per-interface data structure
253 struct hostapd_iface {
254 struct hapd_interfaces *interfaces;
257 struct hostapd_config *conf;
258 char phy[16]; /* Name of the PHY (radio) */
260 enum hostapd_iface_state {
261 HAPD_IFACE_UNINITIALIZED,
263 HAPD_IFACE_COUNTRY_UPDATE,
271 struct hostapd_data **bss;
273 unsigned int wait_channel_update:1;
274 unsigned int cac_started:1;
276 int num_ap; /* number of entries in ap_list */
277 struct ap_info *ap_list; /* AP info list head */
278 struct ap_info *ap_hash[STA_HASH_SIZE];
280 unsigned int drv_flags;
283 * A bitmap of supported protocols for probe response offload. See
284 * struct wpa_driver_capa in driver.h
286 unsigned int probe_resp_offloads;
288 /* extended capabilities supported by the driver */
289 const u8 *extended_capa, *extended_capa_mask;
290 unsigned int extended_capa_len;
292 unsigned int drv_max_acl_mac_addrs;
294 struct hostapd_hw_modes *hw_features;
296 struct hostapd_hw_modes *current_mode;
297 /* Rates that are currently used (i.e., filtered copy of
298 * current_mode->channels */
300 struct hostapd_rate_data *current_rates;
306 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
310 /* Number of associated stations that do not support Short Slot Time */
311 int num_sta_no_short_slot_time;
313 /* Number of associated stations that do not support Short Preamble */
314 int num_sta_no_short_preamble;
316 int olbc; /* Overlapping Legacy BSS Condition */
318 /* Number of HT associated stations that do not support greenfield */
319 int num_sta_ht_no_gf;
321 /* Number of associated non-HT stations */
324 /* Number of HT associated stations 20 MHz */
325 int num_sta_ht_20mhz;
327 /* Overlapping BSS information */
332 /* surveying helpers */
334 /* number of channels surveyed */
335 unsigned int chans_surveyed;
337 /* lowest observed noise floor in dBm */
340 /* channel switch parameters */
341 struct hostapd_freq_params cs_freq_params;
344 unsigned int cs_c_off_beacon;
345 unsigned int cs_c_off_proberesp;
349 unsigned int acs_num_completed_scans;
350 #endif /* CONFIG_ACS */
352 void (*scan_cb)(struct hostapd_iface *iface);
356 * struct hostapd_dynamic_iface - hostapd per dynamically allocated
357 * or added interface data structure
359 struct hostapd_dynamic_iface {
360 char parent[IFNAMSIZ + 1];
361 char iface[IFNAMSIZ + 1];
366 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
367 int (*cb)(struct hostapd_iface *iface,
368 void *ctx), void *ctx);
369 int hostapd_reload_config(struct hostapd_iface *iface);
370 struct hostapd_data *
371 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
372 struct hostapd_config *conf,
373 struct hostapd_bss_config *bss);
374 int hostapd_setup_interface(struct hostapd_iface *iface);
375 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
376 void hostapd_interface_deinit(struct hostapd_iface *iface);
377 void hostapd_interface_free(struct hostapd_iface *iface);
378 struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
379 const char *config_file);
380 struct hostapd_iface *
381 hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
382 const char *config_fname, int debug);
383 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
385 void hostapd_interface_deinit_free(struct hostapd_iface *iface);
386 int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
387 int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
388 int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
389 int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
390 int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
391 void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
392 void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
393 const char * hostapd_state_text(enum hostapd_iface_state s);
394 int hostapd_switch_channel(struct hostapd_data *hapd,
395 struct csa_settings *settings);
396 void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
399 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
400 int (*cb)(void *ctx, const u8 *sa,
401 const u8 *da, const u8 *bssid,
402 const u8 *ie, size_t ie_len,
405 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
407 /* drv_callbacks.c (TODO: move to somewhere else?) */
408 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
409 const u8 *ie, size_t ielen, int reassoc);
410 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
411 void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
412 void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
413 const u8 *addr, int reason_code);
414 int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
415 const u8 *bssid, const u8 *ie, size_t ie_len,
417 void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
418 int offset, int width, int cf1, int cf2);
420 const struct hostapd_eap_user *
421 hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
422 size_t identity_len, int phase2);
424 #endif /* HOSTAPD_H */