blob: bc288056835d2d464b5a3fe2afae115988156081 [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;
18struct hapd_interfaces;
19struct hostapd_data;
20struct sta_info;
21struct hostap_sta_driver_data;
22struct ieee80211_ht_capabilities;
23struct full_dynamic_vlan;
24enum wps_event;
25union wps_event_data;
26
27struct hostapd_probereq_cb {
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080028 int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
29 const u8 *ie, size_t ie_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070030 void *ctx;
31};
32
33#define HOSTAPD_RATE_BASIC 0x00000001
34
35struct hostapd_rate_data {
36 int rate; /* rate in 100 kbps */
37 int flags; /* HOSTAPD_RATE_ flags */
38};
39
40struct 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 */
50struct 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 Shmidt1f69aa52012-01-24 16:10:04 -080079 void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070080
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 Shmidt1f69aa52012-01-24 16:10:04 -0800106 /* Time Advertisement */
107 u8 time_update_counter;
108 struct wpabuf *time_adv;
109
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700110#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 Shmidt1f69aa52012-01-24 16:10:04 -0800117 int beacon_set_done;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700118 struct wpabuf *wps_beacon_ie;
119 struct wpabuf *wps_probe_resp_ie;
120#ifdef CONFIG_WPS
121 unsigned int ap_pin_failures;
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800122 unsigned int ap_pin_failures_consecutive;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700123 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 Shmidt1f69aa52012-01-24 16:10:04 -0800147 int authorized, const u8 *p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700148 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 */
173struct 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 Shmidt1f69aa52012-01-24 16:10:04 -0800190
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 Shmidt8d520ff2011-05-09 14:06:53 -0700197 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 Shmidt1f69aa52012-01-24 16:10:04 -0800204 int *basic_rates;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700205 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 */
245int hostapd_reload_config(struct hostapd_iface *iface);
246struct hostapd_data *
247hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
248 struct hostapd_config *conf,
249 struct hostapd_bss_config *bss);
250int hostapd_setup_interface(struct hostapd_iface *iface);
251int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
252void hostapd_interface_deinit(struct hostapd_iface *iface);
253void hostapd_interface_free(struct hostapd_iface *iface);
254void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
255 int reassoc);
256
257/* utils.c */
258int hostapd_register_probereq_cb(struct hostapd_data *hapd,
259 int (*cb)(void *ctx, const u8 *sa,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800260 const u8 *da, const u8 *bssid,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700261 const u8 *ie, size_t ie_len),
262 void *ctx);
263void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
264
265/* drv_callbacks.c (TODO: move to somewhere else?) */
266int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
267 const u8 *ie, size_t ielen, int reassoc);
268void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
269void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800270int 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 Shmidt8d520ff2011-05-09 14:06:53 -0700272
273#endif /* HOSTAPD_H */