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