Removed hostapd_new_assoc_sta() from driver wrapper API
[mech_eap.orig] / hostapd / 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
29 #ifdef CONFIG_FULL_DYNAMIC_VLAN
30 struct full_dynamic_vlan;
31 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
32
33 struct hostapd_probereq_cb {
34         void (*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
46 struct hostapd_driver_ops {
47         int (*set_ap_wps_ie)(struct hostapd_data *hapd,
48                              const struct wpabuf *beacon,
49                              const struct wpabuf *probe);
50         int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
51                                size_t len);
52         int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr,
53                           const u8 *data, size_t data_len, int encrypt);
54         int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta,
55                               int authorized);
56         int (*set_key)(const char *ifname, struct hostapd_data *hapd,
57                        wpa_alg alg, const u8 *addr, int key_idx,
58                        int set_tx, const u8 *seq, size_t seq_len,
59                        const u8 *key, size_t key_len);
60         int (*read_sta_data)(struct hostapd_data *hapd,
61                              struct hostap_sta_driver_data *data,
62                              const u8 *addr);
63         int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr);
64         int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta);
65         int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname,
66                                  int enabled);
67 };
68
69 /**
70  * struct hostapd_data - hostapd per-BSS data structure
71  */
72 struct hostapd_data {
73         struct hostapd_iface *iface;
74         struct hostapd_config *iconf;
75         struct hostapd_bss_config *conf;
76         int interface_added; /* virtual interface added for this BSS */
77
78         u8 own_addr[ETH_ALEN];
79
80         int num_sta; /* number of entries in sta_list */
81         struct sta_info *sta_list; /* STA info list head */
82 #define STA_HASH_SIZE 256
83 #define STA_HASH(sta) (sta[5])
84         struct sta_info *sta_hash[STA_HASH_SIZE];
85
86         /*
87          * Bitfield for indicating which AIDs are allocated. Only AID values
88          * 1-2007 are used and as such, the bit at index 0 corresponds to AID
89          * 1.
90          */
91 #define AID_WORDS ((2008 + 31) / 32)
92         u32 sta_aid[AID_WORDS];
93
94         const struct wpa_driver_ops *driver;
95         void *drv_priv;
96         struct hostapd_driver_ops drv;
97
98         void *msg_ctx; /* ctx for wpa_msg() calls */
99
100         struct radius_client_data *radius;
101         u32 acct_session_id_hi, acct_session_id_lo;
102
103         struct iapp_data *iapp;
104
105         struct hostapd_cached_radius_acl *acl_cache;
106         struct hostapd_acl_query_data *acl_queries;
107
108         struct wpa_authenticator *wpa_auth;
109         struct eapol_authenticator *eapol_auth;
110
111         struct rsn_preauth_interface *preauth_iface;
112         time_t michael_mic_failure;
113         int michael_mic_failures;
114         int tkip_countermeasures;
115
116         int ctrl_sock;
117         struct wpa_ctrl_dst *ctrl_dst;
118
119         void *ssl_ctx;
120         void *eap_sim_db_priv;
121         struct radius_server_data *radius_srv;
122
123         int parameter_set_count;
124
125 #ifdef CONFIG_FULL_DYNAMIC_VLAN
126         struct full_dynamic_vlan *full_dynamic_vlan;
127 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
128
129         struct l2_packet_data *l2;
130         struct wps_context *wps;
131
132 #ifdef CONFIG_WPS
133         struct wpabuf *wps_beacon_ie;
134         struct wpabuf *wps_probe_resp_ie;
135         unsigned int ap_pin_failures;
136         struct upnp_wps_device_sm *wps_upnp;
137 #endif /* CONFIG_WPS */
138
139         struct hostapd_probereq_cb *probereq_cb;
140         size_t num_probereq_cb;
141 };
142
143
144 /**
145  * struct hostapd_iface - hostapd per-interface data structure
146  */
147 struct hostapd_iface {
148         struct hapd_interfaces *interfaces;
149         void *owner;
150         struct hostapd_config * (*config_read_cb)(const char *config_fname);
151         char *config_fname;
152         struct hostapd_config *conf;
153
154         size_t num_bss;
155         struct hostapd_data **bss;
156
157         int num_ap; /* number of entries in ap_list */
158         struct ap_info *ap_list; /* AP info list head */
159         struct ap_info *ap_hash[STA_HASH_SIZE];
160         struct ap_info *ap_iter_list;
161
162         struct hostapd_hw_modes *hw_features;
163         int num_hw_features;
164         struct hostapd_hw_modes *current_mode;
165         /* Rates that are currently used (i.e., filtered copy of
166          * current_mode->channels */
167         int num_rates;
168         struct hostapd_rate_data *current_rates;
169
170         u16 hw_flags;
171
172         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
173          * in 802.11g BSS) */
174         int num_sta_non_erp;
175
176         /* Number of associated stations that do not support Short Slot Time */
177         int num_sta_no_short_slot_time;
178
179         /* Number of associated stations that do not support Short Preamble */
180         int num_sta_no_short_preamble;
181
182         int olbc; /* Overlapping Legacy BSS Condition */
183
184         /* Number of HT associated stations that do not support greenfield */
185         int num_sta_ht_no_gf;
186
187         /* Number of associated non-HT stations */
188         int num_sta_no_ht;
189
190         /* Number of HT associated stations 20 MHz */
191         int num_sta_ht_20mhz;
192
193         /* Overlapping BSS information */
194         int olbc_ht;
195
196         u16 ht_op_mode;
197         void (*scan_cb)(struct hostapd_iface *iface);
198 };
199
200 int hostapd_reload_config(struct hostapd_iface *iface);
201 struct hostapd_data *
202 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
203                        struct hostapd_config *conf,
204                        struct hostapd_bss_config *bss);
205 int hostapd_setup_interface(struct hostapd_iface *iface);
206 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
207 void hostapd_interface_deinit(struct hostapd_iface *iface);
208 int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
209 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
210
211 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
212                                int (*cb)(struct hostapd_iface *iface,
213                                          void *ctx), void *ctx);
214
215 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
216                                  void (*cb)(void *ctx, const u8 *sa,
217                                             const u8 *ie, size_t ie_len),
218                                  void *ctx);
219
220 int eap_server_register_methods(void);
221 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
222 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
223                            int reassoc);
224
225 #endif /* HOSTAPD_H */