remove @EAP_LDFLAGS@, no longer exists
[mech_eap.orig] / libeap / 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 *ie, size_t ie_len);
35         void *ctx;
36 };
37
38 #define HOSTAPD_RATE_BASIC 0x00000001
39
40 struct hostapd_rate_data {
41         int rate; /* rate in 100 kbps */
42         int flags; /* HOSTAPD_RATE_ flags */
43 };
44
45 struct hostapd_frame_info {
46         u32 channel;
47         u32 datarate;
48         u32 ssi_signal;
49 };
50
51
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,
55                                size_t len);
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,
59                               int authorized);
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,
66                              const u8 *addr);
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,
70                                  int enabled);
71         int (*set_radius_acl_auth)(struct hostapd_data *hapd,
72                                    const u8 *mac, int accepted,
73                                    u32 session_timeout);
74         int (*set_radius_acl_expire)(struct hostapd_data *hapd,
75                                      const u8 *mac);
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,
80                           int beacon_int);
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,
84                            int val);
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,
89                           int reason);
90         int (*sta_disassoc)(struct hostapd_data *hapd, const u8 *addr,
91                             int reason);
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,
95                        u16 listen_interval,
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);
99 };
100
101 /**
102  * struct hostapd_data - hostapd per-BSS data structure
103  */
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 */
109
110         u8 own_addr[ETH_ALEN];
111
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];
117
118         /*
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
121          * 1.
122          */
123 #define AID_WORDS ((2008 + 31) / 32)
124         u32 sta_aid[AID_WORDS];
125
126         const struct wpa_driver_ops *driver;
127         void *drv_priv;
128         struct hostapd_driver_ops drv;
129
130         void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
131                                  struct sta_info *sta, int reassoc);
132
133         void *msg_ctx; /* ctx for wpa_msg() calls */
134
135         struct radius_client_data *radius;
136         u32 acct_session_id_hi, acct_session_id_lo;
137
138         struct iapp_data *iapp;
139
140         struct hostapd_cached_radius_acl *acl_cache;
141         struct hostapd_acl_query_data *acl_queries;
142
143         struct wpa_authenticator *wpa_auth;
144         struct eapol_authenticator *eapol_auth;
145
146         struct rsn_preauth_interface *preauth_iface;
147         time_t michael_mic_failure;
148         int michael_mic_failures;
149         int tkip_countermeasures;
150
151         int ctrl_sock;
152         struct wpa_ctrl_dst *ctrl_dst;
153
154         void *ssl_ctx;
155         void *eap_sim_db_priv;
156         struct radius_server_data *radius_srv;
157
158         int parameter_set_count;
159
160 #ifdef CONFIG_FULL_DYNAMIC_VLAN
161         struct full_dynamic_vlan *full_dynamic_vlan;
162 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
163
164         struct l2_packet_data *l2;
165         struct wps_context *wps;
166
167         struct wpabuf *wps_beacon_ie;
168         struct wpabuf *wps_probe_resp_ie;
169 #ifdef CONFIG_WPS
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 */
174
175         struct hostapd_probereq_cb *probereq_cb;
176         size_t num_probereq_cb;
177
178         void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
179                                  int freq);
180         void *public_action_cb_ctx;
181
182         int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
183                                 int freq);
184         void *vendor_action_cb_ctx;
185
186         void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
187                                    const u8 *uuid_e);
188         void *wps_reg_success_cb_ctx;
189
190         void (*wps_event_cb)(void *ctx, enum wps_event event,
191                              union wps_event_data *data);
192         void *wps_event_cb_ctx;
193
194 #ifdef CONFIG_P2P
195         struct p2p_data *p2p;
196         struct p2p_group *p2p_group;
197         struct wpabuf *p2p_beacon_ie;
198         struct wpabuf *p2p_probe_resp_ie;
199
200         /* Number of non-P2P association stations */
201         int num_sta_no_p2p;
202
203         /* Periodic NoA (used only when no non-P2P clients in the group) */
204         int noa_enabled;
205         int noa_start;
206         int noa_duration;
207 #endif /* CONFIG_P2P */
208 };
209
210
211 /**
212  * struct hostapd_iface - hostapd per-interface data structure
213  */
214 struct hostapd_iface {
215         struct hapd_interfaces *interfaces;
216         void *owner;
217         int (*reload_config)(struct hostapd_iface *iface);
218         struct hostapd_config * (*config_read_cb)(const char *config_fname);
219         char *config_fname;
220         struct hostapd_config *conf;
221
222         size_t num_bss;
223         struct hostapd_data **bss;
224
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;
229
230         struct hostapd_hw_modes *hw_features;
231         int num_hw_features;
232         struct hostapd_hw_modes *current_mode;
233         /* Rates that are currently used (i.e., filtered copy of
234          * current_mode->channels */
235         int num_rates;
236         struct hostapd_rate_data *current_rates;
237         int freq;
238
239         u16 hw_flags;
240
241         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
242          * in 802.11g BSS) */
243         int num_sta_non_erp;
244
245         /* Number of associated stations that do not support Short Slot Time */
246         int num_sta_no_short_slot_time;
247
248         /* Number of associated stations that do not support Short Preamble */
249         int num_sta_no_short_preamble;
250
251         int olbc; /* Overlapping Legacy BSS Condition */
252
253         /* Number of HT associated stations that do not support greenfield */
254         int num_sta_ht_no_gf;
255
256         /* Number of associated non-HT stations */
257         int num_sta_no_ht;
258
259         /* Number of HT associated stations 20 MHz */
260         int num_sta_ht_20mhz;
261
262         /* Overlapping BSS information */
263         int olbc_ht;
264
265         u16 ht_op_mode;
266         void (*scan_cb)(struct hostapd_iface *iface);
267
268         int (*ctrl_iface_init)(struct hostapd_data *hapd);
269         void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
270
271         int (*for_each_interface)(struct hapd_interfaces *interfaces,
272                                   int (*cb)(struct hostapd_iface *iface,
273                                             void *ctx), void *ctx);
274 };
275
276 /* hostapd.c */
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,
287                            int reassoc);
288
289 /* utils.c */
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),
293                                  void *ctx);
294 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
295
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);
300
301 #endif /* HOSTAPD_H */