blob: f7ed31106d605062854929c452852f474d58f3eb [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef HOSTAPD_H
10#define HOSTAPD_H
11
12#include "common/defs.h"
13
14struct wpa_driver_ops;
15struct wpa_ctrl_dst;
16struct radius_server_data;
17struct upnp_wps_device_sm;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070018struct hostapd_data;
19struct sta_info;
20struct hostap_sta_driver_data;
21struct ieee80211_ht_capabilities;
22struct full_dynamic_vlan;
23enum wps_event;
24union wps_event_data;
25
Dmitry Shmidt04949592012-07-19 12:16:46 -070026struct hapd_interfaces {
27 size_t count;
28 struct hostapd_iface **iface;
29};
30
31
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070032struct hostapd_probereq_cb {
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080033 int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
Dmitry Shmidt04949592012-07-19 12:16:46 -070034 const u8 *ie, size_t ie_len, int ssi_signal);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070035 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;
Dmitry Shmidt04949592012-07-19 12:16:46 -070048 int ssi_signal; /* dBm */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070049};
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 */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080084 void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070085
86 struct radius_client_data *radius;
87 u32 acct_session_id_hi, acct_session_id_lo;
Dmitry Shmidt04949592012-07-19 12:16:46 -070088 struct radius_das_data *radius_das;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070089
90 struct iapp_data *iapp;
91
92 struct hostapd_cached_radius_acl *acl_cache;
93 struct hostapd_acl_query_data *acl_queries;
94
95 struct wpa_authenticator *wpa_auth;
96 struct eapol_authenticator *eapol_auth;
97
98 struct rsn_preauth_interface *preauth_iface;
99 time_t michael_mic_failure;
100 int michael_mic_failures;
101 int tkip_countermeasures;
102
103 int ctrl_sock;
104 struct wpa_ctrl_dst *ctrl_dst;
105
106 void *ssl_ctx;
107 void *eap_sim_db_priv;
108 struct radius_server_data *radius_srv;
109
110 int parameter_set_count;
111
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800112 /* Time Advertisement */
113 u8 time_update_counter;
114 struct wpabuf *time_adv;
115
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700116#ifdef CONFIG_FULL_DYNAMIC_VLAN
117 struct full_dynamic_vlan *full_dynamic_vlan;
118#endif /* CONFIG_FULL_DYNAMIC_VLAN */
119
120 struct l2_packet_data *l2;
121 struct wps_context *wps;
122
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800123 int beacon_set_done;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700124 struct wpabuf *wps_beacon_ie;
125 struct wpabuf *wps_probe_resp_ie;
126#ifdef CONFIG_WPS
127 unsigned int ap_pin_failures;
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800128 unsigned int ap_pin_failures_consecutive;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700129 struct upnp_wps_device_sm *wps_upnp;
130 unsigned int ap_pin_lockout_time;
131#endif /* CONFIG_WPS */
132
133 struct hostapd_probereq_cb *probereq_cb;
134 size_t num_probereq_cb;
135
136 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
137 int freq);
138 void *public_action_cb_ctx;
139
140 int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
141 int freq);
142 void *vendor_action_cb_ctx;
143
144 void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
145 const u8 *uuid_e);
146 void *wps_reg_success_cb_ctx;
147
148 void (*wps_event_cb)(void *ctx, enum wps_event event,
149 union wps_event_data *data);
150 void *wps_event_cb_ctx;
151
152 void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800153 int authorized, const u8 *p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700154 void *sta_authorized_cb_ctx;
155
156 void (*setup_complete_cb)(void *ctx);
157 void *setup_complete_cb_ctx;
158
159#ifdef CONFIG_P2P
160 struct p2p_data *p2p;
161 struct p2p_group *p2p_group;
162 struct wpabuf *p2p_beacon_ie;
163 struct wpabuf *p2p_probe_resp_ie;
164
165 /* Number of non-P2P association stations */
166 int num_sta_no_p2p;
167
168 /* Periodic NoA (used only when no non-P2P clients in the group) */
169 int noa_enabled;
170 int noa_start;
171 int noa_duration;
172#endif /* CONFIG_P2P */
Dmitry Shmidt04949592012-07-19 12:16:46 -0700173#ifdef CONFIG_INTERWORKING
174 size_t gas_frag_limit;
175#endif /* CONFIG_INTERWORKING */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700176};
177
178
179/**
180 * struct hostapd_iface - hostapd per-interface data structure
181 */
182struct hostapd_iface {
183 struct hapd_interfaces *interfaces;
184 void *owner;
185 int (*reload_config)(struct hostapd_iface *iface);
186 struct hostapd_config * (*config_read_cb)(const char *config_fname);
187 char *config_fname;
188 struct hostapd_config *conf;
189
190 size_t num_bss;
191 struct hostapd_data **bss;
192
193 int num_ap; /* number of entries in ap_list */
194 struct ap_info *ap_list; /* AP info list head */
195 struct ap_info *ap_hash[STA_HASH_SIZE];
196 struct ap_info *ap_iter_list;
197
198 unsigned int drv_flags;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800199
200 /*
201 * A bitmap of supported protocols for probe response offload. See
202 * struct wpa_driver_capa in driver.h
203 */
204 unsigned int probe_resp_offloads;
205
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700206 struct hostapd_hw_modes *hw_features;
207 int num_hw_features;
208 struct hostapd_hw_modes *current_mode;
209 /* Rates that are currently used (i.e., filtered copy of
210 * current_mode->channels */
211 int num_rates;
212 struct hostapd_rate_data *current_rates;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800213 int *basic_rates;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700214 int freq;
215
216 u16 hw_flags;
217
218 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
219 * in 802.11g BSS) */
220 int num_sta_non_erp;
221
222 /* Number of associated stations that do not support Short Slot Time */
223 int num_sta_no_short_slot_time;
224
225 /* Number of associated stations that do not support Short Preamble */
226 int num_sta_no_short_preamble;
227
228 int olbc; /* Overlapping Legacy BSS Condition */
229
230 /* Number of HT associated stations that do not support greenfield */
231 int num_sta_ht_no_gf;
232
233 /* Number of associated non-HT stations */
234 int num_sta_no_ht;
235
236 /* Number of HT associated stations 20 MHz */
237 int num_sta_ht_20mhz;
238
239 /* Overlapping BSS information */
240 int olbc_ht;
241
242 u16 ht_op_mode;
243 void (*scan_cb)(struct hostapd_iface *iface);
244
245 int (*ctrl_iface_init)(struct hostapd_data *hapd);
246 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
247
248 int (*for_each_interface)(struct hapd_interfaces *interfaces,
249 int (*cb)(struct hostapd_iface *iface,
250 void *ctx), void *ctx);
251};
252
253/* hostapd.c */
Dmitry Shmidt04949592012-07-19 12:16:46 -0700254int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
255 int (*cb)(struct hostapd_iface *iface,
256 void *ctx), void *ctx);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700257int hostapd_reload_config(struct hostapd_iface *iface);
258struct hostapd_data *
259hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
260 struct hostapd_config *conf,
261 struct hostapd_bss_config *bss);
262int hostapd_setup_interface(struct hostapd_iface *iface);
263int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
264void hostapd_interface_deinit(struct hostapd_iface *iface);
265void hostapd_interface_free(struct hostapd_iface *iface);
266void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
267 int reassoc);
268
269/* utils.c */
270int hostapd_register_probereq_cb(struct hostapd_data *hapd,
271 int (*cb)(void *ctx, const u8 *sa,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800272 const u8 *da, const u8 *bssid,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700273 const u8 *ie, size_t ie_len,
274 int ssi_signal),
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700275 void *ctx);
276void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
277
278/* drv_callbacks.c (TODO: move to somewhere else?) */
279int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
280 const u8 *ie, size_t ielen, int reassoc);
281void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
282void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800283int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700284 const u8 *bssid, const u8 *ie, size_t ie_len,
285 int ssi_signal);
286void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
287 int offset);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700288
289#endif /* HOSTAPD_H */