2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "common/defs.h"
20 struct wpa_driver_ops;
22 struct radius_server_data;
23 struct upnp_wps_device_sm;
24 struct hapd_interfaces;
27 struct hostap_sta_driver_data;
28 struct ieee80211_ht_capabilities;
29 struct full_dynamic_vlan;
33 struct hostapd_probereq_cb {
34 int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
38 #define HOSTAPD_RATE_BASIC 0x00000001
40 struct hostapd_rate_data {
41 int rate; /* rate in 100 kbps */
42 int flags; /* HOSTAPD_RATE_ flags */
45 struct hostapd_frame_info {
52 struct hostapd_driver_ops {
53 int (*set_ap_wps_ie)(struct hostapd_data *hapd);
54 int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
56 int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
57 const u8 *data, size_t data_len, int encrypt);
58 int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
60 int (*set_key)(const char *ifname, struct hostapd_data *hapd,
61 enum wpa_alg alg, const u8 *addr, int key_idx,
62 int set_tx, const u8 *seq, size_t seq_len,
63 const u8 *key, size_t key_len);
64 int (*read_sta_data)(struct hostapd_data *hapd,
65 struct hostap_sta_driver_data *data,
67 int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr);
68 int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta);
69 int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname,
71 int (*set_radius_acl_auth)(struct hostapd_data *hapd,
72 const u8 *mac, int accepted,
74 int (*set_radius_acl_expire)(struct hostapd_data *hapd,
76 int (*set_bss_params)(struct hostapd_data *hapd, int use_protection);
77 int (*set_beacon)(struct hostapd_data *hapd,
78 const u8 *head, size_t head_len,
79 const u8 *tail, size_t tail_len, int dtim_period,
81 int (*vlan_if_add)(struct hostapd_data *hapd, const char *ifname);
82 int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname);
83 int (*set_wds_sta)(struct hostapd_data *hapd, const u8 *addr, int aid,
85 int (*set_sta_vlan)(const char *ifname, struct hostapd_data *hapd,
86 const u8 *addr, int vlan_id);
87 int (*get_inact_sec)(struct hostapd_data *hapd, const u8 *addr);
88 int (*sta_deauth)(struct hostapd_data *hapd, const u8 *addr,
90 int (*sta_disassoc)(struct hostapd_data *hapd, const u8 *addr,
92 int (*sta_add)(struct hostapd_data *hapd,
93 const u8 *addr, u16 aid, u16 capability,
94 const u8 *supp_rates, size_t supp_rates_len,
96 const struct ieee80211_ht_capabilities *ht_capab);
97 int (*sta_remove)(struct hostapd_data *hapd, const u8 *addr);
98 int (*set_countermeasures)(struct hostapd_data *hapd, int enabled);
102 * struct hostapd_data - hostapd per-BSS data structure
104 struct hostapd_data {
105 struct hostapd_iface *iface;
106 struct hostapd_config *iconf;
107 struct hostapd_bss_config *conf;
108 int interface_added; /* virtual interface added for this BSS */
110 u8 own_addr[ETH_ALEN];
112 int num_sta; /* number of entries in sta_list */
113 struct sta_info *sta_list; /* STA info list head */
114 #define STA_HASH_SIZE 256
115 #define STA_HASH(sta) (sta[5])
116 struct sta_info *sta_hash[STA_HASH_SIZE];
119 * Bitfield for indicating which AIDs are allocated. Only AID values
120 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
123 #define AID_WORDS ((2008 + 31) / 32)
124 u32 sta_aid[AID_WORDS];
126 const struct wpa_driver_ops *driver;
128 struct hostapd_driver_ops drv;
130 void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
131 struct sta_info *sta, int reassoc);
133 void *msg_ctx; /* ctx for wpa_msg() calls */
135 struct radius_client_data *radius;
136 u32 acct_session_id_hi, acct_session_id_lo;
138 struct iapp_data *iapp;
140 struct hostapd_cached_radius_acl *acl_cache;
141 struct hostapd_acl_query_data *acl_queries;
143 struct wpa_authenticator *wpa_auth;
144 struct eapol_authenticator *eapol_auth;
146 struct rsn_preauth_interface *preauth_iface;
147 time_t michael_mic_failure;
148 int michael_mic_failures;
149 int tkip_countermeasures;
152 struct wpa_ctrl_dst *ctrl_dst;
155 void *eap_sim_db_priv;
156 struct radius_server_data *radius_srv;
158 int parameter_set_count;
160 #ifdef CONFIG_FULL_DYNAMIC_VLAN
161 struct full_dynamic_vlan *full_dynamic_vlan;
162 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
164 struct l2_packet_data *l2;
165 struct wps_context *wps;
167 struct wpabuf *wps_beacon_ie;
168 struct wpabuf *wps_probe_resp_ie;
170 unsigned int ap_pin_failures;
171 struct upnp_wps_device_sm *wps_upnp;
172 unsigned int ap_pin_lockout_time;
173 #endif /* CONFIG_WPS */
175 struct hostapd_probereq_cb *probereq_cb;
176 size_t num_probereq_cb;
178 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
180 void *public_action_cb_ctx;
182 int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
184 void *vendor_action_cb_ctx;
186 void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
188 void *wps_reg_success_cb_ctx;
190 void (*wps_event_cb)(void *ctx, enum wps_event event,
191 union wps_event_data *data);
192 void *wps_event_cb_ctx;
195 struct p2p_data *p2p;
196 struct p2p_group *p2p_group;
197 struct wpabuf *p2p_beacon_ie;
198 struct wpabuf *p2p_probe_resp_ie;
200 /* Number of non-P2P association stations */
203 /* Periodic NoA (used only when no non-P2P clients in the group) */
207 #endif /* CONFIG_P2P */
212 * struct hostapd_iface - hostapd per-interface data structure
214 struct hostapd_iface {
215 struct hapd_interfaces *interfaces;
217 int (*reload_config)(struct hostapd_iface *iface);
218 struct hostapd_config * (*config_read_cb)(const char *config_fname);
220 struct hostapd_config *conf;
223 struct hostapd_data **bss;
225 int num_ap; /* number of entries in ap_list */
226 struct ap_info *ap_list; /* AP info list head */
227 struct ap_info *ap_hash[STA_HASH_SIZE];
228 struct ap_info *ap_iter_list;
230 struct hostapd_hw_modes *hw_features;
232 struct hostapd_hw_modes *current_mode;
233 /* Rates that are currently used (i.e., filtered copy of
234 * current_mode->channels */
236 struct hostapd_rate_data *current_rates;
241 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
245 /* Number of associated stations that do not support Short Slot Time */
246 int num_sta_no_short_slot_time;
248 /* Number of associated stations that do not support Short Preamble */
249 int num_sta_no_short_preamble;
251 int olbc; /* Overlapping Legacy BSS Condition */
253 /* Number of HT associated stations that do not support greenfield */
254 int num_sta_ht_no_gf;
256 /* Number of associated non-HT stations */
259 /* Number of HT associated stations 20 MHz */
260 int num_sta_ht_20mhz;
262 /* Overlapping BSS information */
266 void (*scan_cb)(struct hostapd_iface *iface);
268 int (*ctrl_iface_init)(struct hostapd_data *hapd);
269 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
271 int (*for_each_interface)(struct hapd_interfaces *interfaces,
272 int (*cb)(struct hostapd_iface *iface,
273 void *ctx), void *ctx);
277 int hostapd_reload_config(struct hostapd_iface *iface);
278 struct hostapd_data *
279 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
280 struct hostapd_config *conf,
281 struct hostapd_bss_config *bss);
282 int hostapd_setup_interface(struct hostapd_iface *iface);
283 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
284 void hostapd_interface_deinit(struct hostapd_iface *iface);
285 void hostapd_interface_free(struct hostapd_iface *iface);
286 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
290 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
291 int (*cb)(void *ctx, const u8 *sa,
292 const u8 *ie, size_t ie_len),
294 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
296 /* drv_callbacks.c (TODO: move to somewhere else?) */
297 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
298 const u8 *ie, size_t ielen);
299 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
301 #endif /* HOSTAPD_H */