Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / Initialization and configuration |
| 3 | * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi> |
| 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame^] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef HOSTAPD_H |
| 10 | #define HOSTAPD_H |
| 11 | |
| 12 | #include "common/defs.h" |
| 13 | |
| 14 | struct wpa_driver_ops; |
| 15 | struct wpa_ctrl_dst; |
| 16 | struct radius_server_data; |
| 17 | struct upnp_wps_device_sm; |
| 18 | struct hapd_interfaces; |
| 19 | struct hostapd_data; |
| 20 | struct sta_info; |
| 21 | struct hostap_sta_driver_data; |
| 22 | struct ieee80211_ht_capabilities; |
| 23 | struct full_dynamic_vlan; |
| 24 | enum wps_event; |
| 25 | union wps_event_data; |
| 26 | |
| 27 | struct hostapd_probereq_cb { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 28 | int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid, |
| 29 | const u8 *ie, size_t ie_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 30 | void *ctx; |
| 31 | }; |
| 32 | |
| 33 | #define HOSTAPD_RATE_BASIC 0x00000001 |
| 34 | |
| 35 | struct hostapd_rate_data { |
| 36 | int rate; /* rate in 100 kbps */ |
| 37 | int flags; /* HOSTAPD_RATE_ flags */ |
| 38 | }; |
| 39 | |
| 40 | struct hostapd_frame_info { |
| 41 | u32 channel; |
| 42 | u32 datarate; |
| 43 | u32 ssi_signal; |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | /** |
| 48 | * struct hostapd_data - hostapd per-BSS data structure |
| 49 | */ |
| 50 | struct hostapd_data { |
| 51 | struct hostapd_iface *iface; |
| 52 | struct hostapd_config *iconf; |
| 53 | struct hostapd_bss_config *conf; |
| 54 | int interface_added; /* virtual interface added for this BSS */ |
| 55 | |
| 56 | u8 own_addr[ETH_ALEN]; |
| 57 | |
| 58 | int num_sta; /* number of entries in sta_list */ |
| 59 | struct sta_info *sta_list; /* STA info list head */ |
| 60 | #define STA_HASH_SIZE 256 |
| 61 | #define STA_HASH(sta) (sta[5]) |
| 62 | struct sta_info *sta_hash[STA_HASH_SIZE]; |
| 63 | |
| 64 | /* |
| 65 | * Bitfield for indicating which AIDs are allocated. Only AID values |
| 66 | * 1-2007 are used and as such, the bit at index 0 corresponds to AID |
| 67 | * 1. |
| 68 | */ |
| 69 | #define AID_WORDS ((2008 + 31) / 32) |
| 70 | u32 sta_aid[AID_WORDS]; |
| 71 | |
| 72 | const struct wpa_driver_ops *driver; |
| 73 | void *drv_priv; |
| 74 | |
| 75 | void (*new_assoc_sta_cb)(struct hostapd_data *hapd, |
| 76 | struct sta_info *sta, int reassoc); |
| 77 | |
| 78 | void *msg_ctx; /* ctx for wpa_msg() calls */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 79 | void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 80 | |
| 81 | struct radius_client_data *radius; |
| 82 | u32 acct_session_id_hi, acct_session_id_lo; |
| 83 | |
| 84 | struct iapp_data *iapp; |
| 85 | |
| 86 | struct hostapd_cached_radius_acl *acl_cache; |
| 87 | struct hostapd_acl_query_data *acl_queries; |
| 88 | |
| 89 | struct wpa_authenticator *wpa_auth; |
| 90 | struct eapol_authenticator *eapol_auth; |
| 91 | |
| 92 | struct rsn_preauth_interface *preauth_iface; |
| 93 | time_t michael_mic_failure; |
| 94 | int michael_mic_failures; |
| 95 | int tkip_countermeasures; |
| 96 | |
| 97 | int ctrl_sock; |
| 98 | struct wpa_ctrl_dst *ctrl_dst; |
| 99 | |
| 100 | void *ssl_ctx; |
| 101 | void *eap_sim_db_priv; |
| 102 | struct radius_server_data *radius_srv; |
| 103 | |
| 104 | int parameter_set_count; |
| 105 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 106 | /* Time Advertisement */ |
| 107 | u8 time_update_counter; |
| 108 | struct wpabuf *time_adv; |
| 109 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 110 | #ifdef CONFIG_FULL_DYNAMIC_VLAN |
| 111 | struct full_dynamic_vlan *full_dynamic_vlan; |
| 112 | #endif /* CONFIG_FULL_DYNAMIC_VLAN */ |
| 113 | |
| 114 | struct l2_packet_data *l2; |
| 115 | struct wps_context *wps; |
| 116 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 117 | int beacon_set_done; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 118 | struct wpabuf *wps_beacon_ie; |
| 119 | struct wpabuf *wps_probe_resp_ie; |
| 120 | #ifdef CONFIG_WPS |
| 121 | unsigned int ap_pin_failures; |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame^] | 122 | unsigned int ap_pin_failures_consecutive; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 123 | struct upnp_wps_device_sm *wps_upnp; |
| 124 | unsigned int ap_pin_lockout_time; |
| 125 | #endif /* CONFIG_WPS */ |
| 126 | |
| 127 | struct hostapd_probereq_cb *probereq_cb; |
| 128 | size_t num_probereq_cb; |
| 129 | |
| 130 | void (*public_action_cb)(void *ctx, const u8 *buf, size_t len, |
| 131 | int freq); |
| 132 | void *public_action_cb_ctx; |
| 133 | |
| 134 | int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len, |
| 135 | int freq); |
| 136 | void *vendor_action_cb_ctx; |
| 137 | |
| 138 | void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr, |
| 139 | const u8 *uuid_e); |
| 140 | void *wps_reg_success_cb_ctx; |
| 141 | |
| 142 | void (*wps_event_cb)(void *ctx, enum wps_event event, |
| 143 | union wps_event_data *data); |
| 144 | void *wps_event_cb_ctx; |
| 145 | |
| 146 | void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 147 | int authorized, const u8 *p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 148 | void *sta_authorized_cb_ctx; |
| 149 | |
| 150 | void (*setup_complete_cb)(void *ctx); |
| 151 | void *setup_complete_cb_ctx; |
| 152 | |
| 153 | #ifdef CONFIG_P2P |
| 154 | struct p2p_data *p2p; |
| 155 | struct p2p_group *p2p_group; |
| 156 | struct wpabuf *p2p_beacon_ie; |
| 157 | struct wpabuf *p2p_probe_resp_ie; |
| 158 | |
| 159 | /* Number of non-P2P association stations */ |
| 160 | int num_sta_no_p2p; |
| 161 | |
| 162 | /* Periodic NoA (used only when no non-P2P clients in the group) */ |
| 163 | int noa_enabled; |
| 164 | int noa_start; |
| 165 | int noa_duration; |
| 166 | #endif /* CONFIG_P2P */ |
| 167 | }; |
| 168 | |
| 169 | |
| 170 | /** |
| 171 | * struct hostapd_iface - hostapd per-interface data structure |
| 172 | */ |
| 173 | struct hostapd_iface { |
| 174 | struct hapd_interfaces *interfaces; |
| 175 | void *owner; |
| 176 | int (*reload_config)(struct hostapd_iface *iface); |
| 177 | struct hostapd_config * (*config_read_cb)(const char *config_fname); |
| 178 | char *config_fname; |
| 179 | struct hostapd_config *conf; |
| 180 | |
| 181 | size_t num_bss; |
| 182 | struct hostapd_data **bss; |
| 183 | |
| 184 | int num_ap; /* number of entries in ap_list */ |
| 185 | struct ap_info *ap_list; /* AP info list head */ |
| 186 | struct ap_info *ap_hash[STA_HASH_SIZE]; |
| 187 | struct ap_info *ap_iter_list; |
| 188 | |
| 189 | unsigned int drv_flags; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 190 | |
| 191 | /* |
| 192 | * A bitmap of supported protocols for probe response offload. See |
| 193 | * struct wpa_driver_capa in driver.h |
| 194 | */ |
| 195 | unsigned int probe_resp_offloads; |
| 196 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 197 | struct hostapd_hw_modes *hw_features; |
| 198 | int num_hw_features; |
| 199 | struct hostapd_hw_modes *current_mode; |
| 200 | /* Rates that are currently used (i.e., filtered copy of |
| 201 | * current_mode->channels */ |
| 202 | int num_rates; |
| 203 | struct hostapd_rate_data *current_rates; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 204 | int *basic_rates; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 205 | int freq; |
| 206 | |
| 207 | u16 hw_flags; |
| 208 | |
| 209 | /* Number of associated Non-ERP stations (i.e., stations using 802.11b |
| 210 | * in 802.11g BSS) */ |
| 211 | int num_sta_non_erp; |
| 212 | |
| 213 | /* Number of associated stations that do not support Short Slot Time */ |
| 214 | int num_sta_no_short_slot_time; |
| 215 | |
| 216 | /* Number of associated stations that do not support Short Preamble */ |
| 217 | int num_sta_no_short_preamble; |
| 218 | |
| 219 | int olbc; /* Overlapping Legacy BSS Condition */ |
| 220 | |
| 221 | /* Number of HT associated stations that do not support greenfield */ |
| 222 | int num_sta_ht_no_gf; |
| 223 | |
| 224 | /* Number of associated non-HT stations */ |
| 225 | int num_sta_no_ht; |
| 226 | |
| 227 | /* Number of HT associated stations 20 MHz */ |
| 228 | int num_sta_ht_20mhz; |
| 229 | |
| 230 | /* Overlapping BSS information */ |
| 231 | int olbc_ht; |
| 232 | |
| 233 | u16 ht_op_mode; |
| 234 | void (*scan_cb)(struct hostapd_iface *iface); |
| 235 | |
| 236 | int (*ctrl_iface_init)(struct hostapd_data *hapd); |
| 237 | void (*ctrl_iface_deinit)(struct hostapd_data *hapd); |
| 238 | |
| 239 | int (*for_each_interface)(struct hapd_interfaces *interfaces, |
| 240 | int (*cb)(struct hostapd_iface *iface, |
| 241 | void *ctx), void *ctx); |
| 242 | }; |
| 243 | |
| 244 | /* hostapd.c */ |
| 245 | int hostapd_reload_config(struct hostapd_iface *iface); |
| 246 | struct hostapd_data * |
| 247 | hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, |
| 248 | struct hostapd_config *conf, |
| 249 | struct hostapd_bss_config *bss); |
| 250 | int hostapd_setup_interface(struct hostapd_iface *iface); |
| 251 | int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err); |
| 252 | void hostapd_interface_deinit(struct hostapd_iface *iface); |
| 253 | void hostapd_interface_free(struct hostapd_iface *iface); |
| 254 | void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, |
| 255 | int reassoc); |
| 256 | |
| 257 | /* utils.c */ |
| 258 | int hostapd_register_probereq_cb(struct hostapd_data *hapd, |
| 259 | int (*cb)(void *ctx, const u8 *sa, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 260 | const u8 *da, const u8 *bssid, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 261 | const u8 *ie, size_t ie_len), |
| 262 | void *ctx); |
| 263 | void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr); |
| 264 | |
| 265 | /* drv_callbacks.c (TODO: move to somewhere else?) */ |
| 266 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, |
| 267 | const u8 *ie, size_t ielen, int reassoc); |
| 268 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr); |
| 269 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 270 | int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, |
| 271 | const u8 *bssid, const u8 *ie, size_t ie_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 272 | |
| 273 | #endif /* HOSTAPD_H */ |