]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/ap/hostapd.h
Fix WPA/RSN IE update on reconfig with set_generic_elem()
[thirdparty/hostap.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
31 struct hostapd_probereq_cb {
32 int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
33 void *ctx;
34 };
35
36 #define HOSTAPD_RATE_BASIC 0x00000001
37
38 struct hostapd_rate_data {
39 int rate; /* rate in 100 kbps */
40 int flags; /* HOSTAPD_RATE_ flags */
41 };
42
43 struct hostapd_frame_info {
44 u32 channel;
45 u32 datarate;
46 u32 ssi_signal;
47 };
48
49
50 struct hostapd_driver_ops {
51 int (*set_ap_wps_ie)(struct hostapd_data *hapd,
52 const struct wpabuf *beacon,
53 const struct wpabuf *probe);
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 #ifdef CONFIG_WPS
168 struct wpabuf *wps_beacon_ie;
169 struct wpabuf *wps_probe_resp_ie;
170 unsigned int ap_pin_failures;
171 struct upnp_wps_device_sm *wps_upnp;
172 #endif /* CONFIG_WPS */
173
174 struct hostapd_probereq_cb *probereq_cb;
175 size_t num_probereq_cb;
176 };
177
178
179 /**
180 * struct hostapd_iface - hostapd per-interface data structure
181 */
182 struct hostapd_iface {
183 struct hapd_interfaces *interfaces;
184 void *owner;
185 int (*reload_config)(struct hostapd_iface *iface);
186 struct hostapd_config * (*config_read_cb)(const char *config_fname);
187 char *config_fname;
188 struct hostapd_config *conf;
189
190 size_t num_bss;
191 struct hostapd_data **bss;
192
193 int num_ap; /* number of entries in ap_list */
194 struct ap_info *ap_list; /* AP info list head */
195 struct ap_info *ap_hash[STA_HASH_SIZE];
196 struct ap_info *ap_iter_list;
197
198 struct hostapd_hw_modes *hw_features;
199 int num_hw_features;
200 struct hostapd_hw_modes *current_mode;
201 /* Rates that are currently used (i.e., filtered copy of
202 * current_mode->channels */
203 int num_rates;
204 struct hostapd_rate_data *current_rates;
205
206 u16 hw_flags;
207
208 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
209 * in 802.11g BSS) */
210 int num_sta_non_erp;
211
212 /* Number of associated stations that do not support Short Slot Time */
213 int num_sta_no_short_slot_time;
214
215 /* Number of associated stations that do not support Short Preamble */
216 int num_sta_no_short_preamble;
217
218 int olbc; /* Overlapping Legacy BSS Condition */
219
220 /* Number of HT associated stations that do not support greenfield */
221 int num_sta_ht_no_gf;
222
223 /* Number of associated non-HT stations */
224 int num_sta_no_ht;
225
226 /* Number of HT associated stations 20 MHz */
227 int num_sta_ht_20mhz;
228
229 /* Overlapping BSS information */
230 int olbc_ht;
231
232 u16 ht_op_mode;
233 void (*scan_cb)(struct hostapd_iface *iface);
234
235 int (*ctrl_iface_init)(struct hostapd_data *hapd);
236 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
237
238 int (*for_each_interface)(struct hapd_interfaces *interfaces,
239 int (*cb)(struct hostapd_iface *iface,
240 void *ctx), void *ctx);
241 };
242
243 /* hostapd.c */
244 int hostapd_reload_config(struct hostapd_iface *iface);
245 struct hostapd_data *
246 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
247 struct hostapd_config *conf,
248 struct hostapd_bss_config *bss);
249 int hostapd_setup_interface(struct hostapd_iface *iface);
250 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
251 void hostapd_interface_deinit(struct hostapd_iface *iface);
252 void hostapd_interface_free(struct hostapd_iface *iface);
253 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
254 int reassoc);
255
256 /* utils.c */
257 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
258 int (*cb)(void *ctx, const u8 *sa,
259 const u8 *ie, size_t ie_len),
260 void *ctx);
261 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
262
263 /* drv_callbacks.c (TODO: move to somewhere else?) */
264 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
265 const u8 *ie, size_t ielen);
266 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
267
268 #endif /* HOSTAPD_H */