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