hostapd.h revision 8d520ff1dc2da35cdca849e982051b86468016d8
11510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org/* 21510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * hostapd / Initialization and configuration 31510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi> 41510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * 51510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * This program is free software; you can redistribute it and/or modify 61510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * it under the terms of the GNU General Public License version 2 as 71510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * published by the Free Software Foundation. 81510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * 91510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * Alternatively, this software may be distributed under the terms of BSD 101510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * license. 111510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * 121510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org * See README and COPYING for more details. 131510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org */ 141510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org 151510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org#ifndef HOSTAPD_H 161510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org#define HOSTAPD_H 171510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org 181510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org#include "common/defs.h" 191510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org 201510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct wpa_driver_ops; 211510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct wpa_ctrl_dst; 221510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct radius_server_data; 231510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct upnp_wps_device_sm; 241510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct hapd_interfaces; 251510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct hostapd_data; 261510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct sta_info; 271510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct hostap_sta_driver_data; 281510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct ieee80211_ht_capabilities; 291510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct full_dynamic_vlan; 301510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgenum wps_event; 311510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgunion wps_event_data; 321510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org 331510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.orgstruct hostapd_probereq_cb { 341510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len); 351510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org void *ctx; 36}; 37 38#define HOSTAPD_RATE_BASIC 0x00000001 39 40struct hostapd_rate_data { 41 int rate; /* rate in 100 kbps */ 42 int flags; /* HOSTAPD_RATE_ flags */ 43}; 44 45struct hostapd_frame_info { 46 u32 channel; 47 u32 datarate; 48 u32 ssi_signal; 49}; 50 51 52/** 53 * struct hostapd_data - hostapd per-BSS data structure 54 */ 55struct hostapd_data { 56 struct hostapd_iface *iface; 57 struct hostapd_config *iconf; 58 struct hostapd_bss_config *conf; 59 int interface_added; /* virtual interface added for this BSS */ 60 61 u8 own_addr[ETH_ALEN]; 62 63 int num_sta; /* number of entries in sta_list */ 64 struct sta_info *sta_list; /* STA info list head */ 65#define STA_HASH_SIZE 256 66#define STA_HASH(sta) (sta[5]) 67 struct sta_info *sta_hash[STA_HASH_SIZE]; 68 69 /* 70 * Bitfield for indicating which AIDs are allocated. Only AID values 71 * 1-2007 are used and as such, the bit at index 0 corresponds to AID 72 * 1. 73 */ 74#define AID_WORDS ((2008 + 31) / 32) 75 u32 sta_aid[AID_WORDS]; 76 77 const struct wpa_driver_ops *driver; 78 void *drv_priv; 79 80 void (*new_assoc_sta_cb)(struct hostapd_data *hapd, 81 struct sta_info *sta, int reassoc); 82 83 void *msg_ctx; /* ctx for wpa_msg() calls */ 84 85 struct radius_client_data *radius; 86 u32 acct_session_id_hi, acct_session_id_lo; 87 88 struct iapp_data *iapp; 89 90 struct hostapd_cached_radius_acl *acl_cache; 91 struct hostapd_acl_query_data *acl_queries; 92 93 struct wpa_authenticator *wpa_auth; 94 struct eapol_authenticator *eapol_auth; 95 96 struct rsn_preauth_interface *preauth_iface; 97 time_t michael_mic_failure; 98 int michael_mic_failures; 99 int tkip_countermeasures; 100 101 int ctrl_sock; 102 struct wpa_ctrl_dst *ctrl_dst; 103 104 void *ssl_ctx; 105 void *eap_sim_db_priv; 106 struct radius_server_data *radius_srv; 107 108 int parameter_set_count; 109 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 117 struct wpabuf *wps_beacon_ie; 118 struct wpabuf *wps_probe_resp_ie; 119#ifdef CONFIG_WPS 120 unsigned int ap_pin_failures; 121 struct upnp_wps_device_sm *wps_upnp; 122 unsigned int ap_pin_lockout_time; 123#endif /* CONFIG_WPS */ 124 125 struct hostapd_probereq_cb *probereq_cb; 126 size_t num_probereq_cb; 127 128 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len, 129 int freq); 130 void *public_action_cb_ctx; 131 132 int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len, 133 int freq); 134 void *vendor_action_cb_ctx; 135 136 void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr, 137 const u8 *uuid_e); 138 void *wps_reg_success_cb_ctx; 139 140 void (*wps_event_cb)(void *ctx, enum wps_event event, 141 union wps_event_data *data); 142 void *wps_event_cb_ctx; 143 144 void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr, 145 int authorized); 146 void *sta_authorized_cb_ctx; 147 148 void (*setup_complete_cb)(void *ctx); 149 void *setup_complete_cb_ctx; 150 151#ifdef CONFIG_P2P 152 struct p2p_data *p2p; 153 struct p2p_group *p2p_group; 154 struct wpabuf *p2p_beacon_ie; 155 struct wpabuf *p2p_probe_resp_ie; 156 157 /* Number of non-P2P association stations */ 158 int num_sta_no_p2p; 159 160 /* Periodic NoA (used only when no non-P2P clients in the group) */ 161 int noa_enabled; 162 int noa_start; 163 int noa_duration; 164#endif /* CONFIG_P2P */ 165}; 166 167 168/** 169 * struct hostapd_iface - hostapd per-interface data structure 170 */ 171struct hostapd_iface { 172 struct hapd_interfaces *interfaces; 173 void *owner; 174 int (*reload_config)(struct hostapd_iface *iface); 175 struct hostapd_config * (*config_read_cb)(const char *config_fname); 176 char *config_fname; 177 struct hostapd_config *conf; 178 179 size_t num_bss; 180 struct hostapd_data **bss; 181 182 int num_ap; /* number of entries in ap_list */ 183 struct ap_info *ap_list; /* AP info list head */ 184 struct ap_info *ap_hash[STA_HASH_SIZE]; 185 struct ap_info *ap_iter_list; 186 187 unsigned int drv_flags; 188 struct hostapd_hw_modes *hw_features; 189 int num_hw_features; 190 struct hostapd_hw_modes *current_mode; 191 /* Rates that are currently used (i.e., filtered copy of 192 * current_mode->channels */ 193 int num_rates; 194 struct hostapd_rate_data *current_rates; 195 int freq; 196 197 u16 hw_flags; 198 199 /* Number of associated Non-ERP stations (i.e., stations using 802.11b 200 * in 802.11g BSS) */ 201 int num_sta_non_erp; 202 203 /* Number of associated stations that do not support Short Slot Time */ 204 int num_sta_no_short_slot_time; 205 206 /* Number of associated stations that do not support Short Preamble */ 207 int num_sta_no_short_preamble; 208 209 int olbc; /* Overlapping Legacy BSS Condition */ 210 211 /* Number of HT associated stations that do not support greenfield */ 212 int num_sta_ht_no_gf; 213 214 /* Number of associated non-HT stations */ 215 int num_sta_no_ht; 216 217 /* Number of HT associated stations 20 MHz */ 218 int num_sta_ht_20mhz; 219 220 /* Overlapping BSS information */ 221 int olbc_ht; 222 223 u16 ht_op_mode; 224 void (*scan_cb)(struct hostapd_iface *iface); 225 226 int (*ctrl_iface_init)(struct hostapd_data *hapd); 227 void (*ctrl_iface_deinit)(struct hostapd_data *hapd); 228 229 int (*for_each_interface)(struct hapd_interfaces *interfaces, 230 int (*cb)(struct hostapd_iface *iface, 231 void *ctx), void *ctx); 232}; 233 234/* hostapd.c */ 235int hostapd_reload_config(struct hostapd_iface *iface); 236struct hostapd_data * 237hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, 238 struct hostapd_config *conf, 239 struct hostapd_bss_config *bss); 240int hostapd_setup_interface(struct hostapd_iface *iface); 241int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err); 242void hostapd_interface_deinit(struct hostapd_iface *iface); 243void hostapd_interface_free(struct hostapd_iface *iface); 244void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, 245 int reassoc); 246 247/* utils.c */ 248int hostapd_register_probereq_cb(struct hostapd_data *hapd, 249 int (*cb)(void *ctx, const u8 *sa, 250 const u8 *ie, size_t ie_len), 251 void *ctx); 252void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr); 253 254/* drv_callbacks.c (TODO: move to somewhere else?) */ 255int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, 256 const u8 *ie, size_t ielen, int reassoc); 257void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr); 258void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr); 259int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, 260 const u8 *ie, size_t ie_len); 261 262#endif /* HOSTAPD_H */ 263