blob: 75d9c66acbf85739022fe71a14821a4ba5a3be85 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / Initialization and configuration
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef HOSTAPD_H
10#define HOSTAPD_H
11
12#include "common/defs.h"
Dmitry Shmidtd5e49232012-12-03 15:08:10 -080013#include "ap_config.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070014
15struct wpa_driver_ops;
16struct wpa_ctrl_dst;
17struct radius_server_data;
18struct upnp_wps_device_sm;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070019struct hostapd_data;
20struct sta_info;
21struct hostap_sta_driver_data;
22struct ieee80211_ht_capabilities;
23struct full_dynamic_vlan;
24enum wps_event;
25union wps_event_data;
26
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070027struct hostapd_iface;
Dmitry Shmidt34af3062013-07-11 10:46:32 -070028struct hostapd_dynamic_iface;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070029
Dmitry Shmidt04949592012-07-19 12:16:46 -070030struct hapd_interfaces {
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070031 int (*reload_config)(struct hostapd_iface *iface);
32 struct hostapd_config * (*config_read_cb)(const char *config_fname);
33 int (*ctrl_iface_init)(struct hostapd_data *hapd);
34 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
35 int (*for_each_interface)(struct hapd_interfaces *interfaces,
36 int (*cb)(struct hostapd_iface *iface,
37 void *ctx), void *ctx);
38 int (*driver_init)(struct hostapd_iface *iface);
39
Dmitry Shmidt04949592012-07-19 12:16:46 -070040 size_t count;
Dmitry Shmidt34af3062013-07-11 10:46:32 -070041 size_t count_dynamic;
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070042 int global_ctrl_sock;
43 char *global_iface_path;
44 char *global_iface_name;
Dmitry Shmidt0ccb66e2013-03-29 16:41:28 -070045 gid_t ctrl_iface_group;
Dmitry Shmidt04949592012-07-19 12:16:46 -070046 struct hostapd_iface **iface;
Dmitry Shmidt34af3062013-07-11 10:46:32 -070047 struct hostapd_dynamic_iface **dynamic_iface;
Dmitry Shmidt04949592012-07-19 12:16:46 -070048};
49
50
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070051struct hostapd_probereq_cb {
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080052 int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
Dmitry Shmidt04949592012-07-19 12:16:46 -070053 const u8 *ie, size_t ie_len, int ssi_signal);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070054 void *ctx;
55};
56
57#define HOSTAPD_RATE_BASIC 0x00000001
58
59struct hostapd_rate_data {
60 int rate; /* rate in 100 kbps */
61 int flags; /* HOSTAPD_RATE_ flags */
62};
63
64struct hostapd_frame_info {
65 u32 channel;
66 u32 datarate;
Dmitry Shmidt04949592012-07-19 12:16:46 -070067 int ssi_signal; /* dBm */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070068};
69
70
71/**
72 * struct hostapd_data - hostapd per-BSS data structure
73 */
74struct hostapd_data {
75 struct hostapd_iface *iface;
76 struct hostapd_config *iconf;
77 struct hostapd_bss_config *conf;
78 int interface_added; /* virtual interface added for this BSS */
79
80 u8 own_addr[ETH_ALEN];
81
82 int num_sta; /* number of entries in sta_list */
83 struct sta_info *sta_list; /* STA info list head */
84#define STA_HASH_SIZE 256
85#define STA_HASH(sta) (sta[5])
86 struct sta_info *sta_hash[STA_HASH_SIZE];
87
88 /*
89 * Bitfield for indicating which AIDs are allocated. Only AID values
90 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
91 * 1.
92 */
93#define AID_WORDS ((2008 + 31) / 32)
94 u32 sta_aid[AID_WORDS];
95
96 const struct wpa_driver_ops *driver;
97 void *drv_priv;
98
99 void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
100 struct sta_info *sta, int reassoc);
101
102 void *msg_ctx; /* ctx for wpa_msg() calls */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800103 void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700104
105 struct radius_client_data *radius;
106 u32 acct_session_id_hi, acct_session_id_lo;
Dmitry Shmidt04949592012-07-19 12:16:46 -0700107 struct radius_das_data *radius_das;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700108
109 struct iapp_data *iapp;
110
111 struct hostapd_cached_radius_acl *acl_cache;
112 struct hostapd_acl_query_data *acl_queries;
113
114 struct wpa_authenticator *wpa_auth;
115 struct eapol_authenticator *eapol_auth;
116
117 struct rsn_preauth_interface *preauth_iface;
118 time_t michael_mic_failure;
119 int michael_mic_failures;
120 int tkip_countermeasures;
121
122 int ctrl_sock;
123 struct wpa_ctrl_dst *ctrl_dst;
124
125 void *ssl_ctx;
126 void *eap_sim_db_priv;
127 struct radius_server_data *radius_srv;
128
129 int parameter_set_count;
130
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800131 /* Time Advertisement */
132 u8 time_update_counter;
133 struct wpabuf *time_adv;
134
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700135#ifdef CONFIG_FULL_DYNAMIC_VLAN
136 struct full_dynamic_vlan *full_dynamic_vlan;
137#endif /* CONFIG_FULL_DYNAMIC_VLAN */
138
139 struct l2_packet_data *l2;
140 struct wps_context *wps;
141
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800142 int beacon_set_done;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700143 struct wpabuf *wps_beacon_ie;
144 struct wpabuf *wps_probe_resp_ie;
145#ifdef CONFIG_WPS
146 unsigned int ap_pin_failures;
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800147 unsigned int ap_pin_failures_consecutive;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700148 struct upnp_wps_device_sm *wps_upnp;
149 unsigned int ap_pin_lockout_time;
150#endif /* CONFIG_WPS */
151
152 struct hostapd_probereq_cb *probereq_cb;
153 size_t num_probereq_cb;
154
155 void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
156 int freq);
157 void *public_action_cb_ctx;
Dmitry Shmidt4b9d52f2013-02-05 17:44:43 -0800158 void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
159 int freq);
160 void *public_action_cb2_ctx;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700161
162 int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
163 int freq);
164 void *vendor_action_cb_ctx;
165
166 void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
167 const u8 *uuid_e);
168 void *wps_reg_success_cb_ctx;
169
170 void (*wps_event_cb)(void *ctx, enum wps_event event,
171 union wps_event_data *data);
172 void *wps_event_cb_ctx;
173
174 void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800175 int authorized, const u8 *p2p_dev_addr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700176 void *sta_authorized_cb_ctx;
177
178 void (*setup_complete_cb)(void *ctx);
179 void *setup_complete_cb_ctx;
180
181#ifdef CONFIG_P2P
182 struct p2p_data *p2p;
183 struct p2p_group *p2p_group;
184 struct wpabuf *p2p_beacon_ie;
185 struct wpabuf *p2p_probe_resp_ie;
186
187 /* Number of non-P2P association stations */
188 int num_sta_no_p2p;
189
190 /* Periodic NoA (used only when no non-P2P clients in the group) */
191 int noa_enabled;
192 int noa_start;
193 int noa_duration;
194#endif /* CONFIG_P2P */
Dmitry Shmidt04949592012-07-19 12:16:46 -0700195#ifdef CONFIG_INTERWORKING
196 size_t gas_frag_limit;
197#endif /* CONFIG_INTERWORKING */
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800198
199#ifdef CONFIG_SQLITE
200 struct hostapd_eap_user tmp_eap_user;
201#endif /* CONFIG_SQLITE */
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800202
203#ifdef CONFIG_SAE
204 /** Key used for generating SAE anti-clogging tokens */
205 u8 sae_token_key[8];
206 os_time_t last_sae_token_key_update;
207#endif /* CONFIG_SAE */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700208};
209
210
211/**
212 * struct hostapd_iface - hostapd per-interface data structure
213 */
214struct hostapd_iface {
215 struct hapd_interfaces *interfaces;
216 void *owner;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700217 char *config_fname;
218 struct hostapd_config *conf;
219
220 size_t num_bss;
221 struct hostapd_data **bss;
222
223 int num_ap; /* number of entries in ap_list */
224 struct ap_info *ap_list; /* AP info list head */
225 struct ap_info *ap_hash[STA_HASH_SIZE];
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700226
227 unsigned int drv_flags;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800228
229 /*
230 * A bitmap of supported protocols for probe response offload. See
231 * struct wpa_driver_capa in driver.h
232 */
233 unsigned int probe_resp_offloads;
234
Dmitry Shmidt444d5672013-04-01 13:08:44 -0700235 /* extended capabilities supported by the driver */
236 const u8 *extended_capa, *extended_capa_mask;
237 unsigned int extended_capa_len;
238
Dmitry Shmidt8bae4132013-06-06 11:25:10 -0700239 unsigned int drv_max_acl_mac_addrs;
240
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700241 struct hostapd_hw_modes *hw_features;
242 int num_hw_features;
243 struct hostapd_hw_modes *current_mode;
244 /* Rates that are currently used (i.e., filtered copy of
245 * current_mode->channels */
246 int num_rates;
247 struct hostapd_rate_data *current_rates;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800248 int *basic_rates;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700249 int freq;
250
251 u16 hw_flags;
252
253 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
254 * in 802.11g BSS) */
255 int num_sta_non_erp;
256
257 /* Number of associated stations that do not support Short Slot Time */
258 int num_sta_no_short_slot_time;
259
260 /* Number of associated stations that do not support Short Preamble */
261 int num_sta_no_short_preamble;
262
263 int olbc; /* Overlapping Legacy BSS Condition */
264
265 /* Number of HT associated stations that do not support greenfield */
266 int num_sta_ht_no_gf;
267
268 /* Number of associated non-HT stations */
269 int num_sta_no_ht;
270
271 /* Number of HT associated stations 20 MHz */
272 int num_sta_ht_20mhz;
273
274 /* Overlapping BSS information */
275 int olbc_ht;
276
277 u16 ht_op_mode;
278 void (*scan_cb)(struct hostapd_iface *iface);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700279};
280
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700281/**
282 * struct hostapd_dynamic_iface - hostapd per dynamically allocated
283 * or added interface data structure
284 */
285struct hostapd_dynamic_iface {
286 char parent[IFNAMSIZ + 1];
287 char iface[IFNAMSIZ + 1];
288 unsigned int usage;
289};
290
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700291/* hostapd.c */
Dmitry Shmidt04949592012-07-19 12:16:46 -0700292int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
293 int (*cb)(struct hostapd_iface *iface,
294 void *ctx), void *ctx);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700295int hostapd_reload_config(struct hostapd_iface *iface);
296struct hostapd_data *
297hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
298 struct hostapd_config *conf,
299 struct hostapd_bss_config *bss);
300int hostapd_setup_interface(struct hostapd_iface *iface);
301int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
302void hostapd_interface_deinit(struct hostapd_iface *iface);
303void hostapd_interface_free(struct hostapd_iface *iface);
304void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
305 int reassoc);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700306void hostapd_interface_deinit_free(struct hostapd_iface *iface);
307int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
308int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
309int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
310int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
311int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700312
313/* utils.c */
314int hostapd_register_probereq_cb(struct hostapd_data *hapd,
315 int (*cb)(void *ctx, const u8 *sa,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800316 const u8 *da, const u8 *bssid,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700317 const u8 *ie, size_t ie_len,
318 int ssi_signal),
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700319 void *ctx);
320void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
321
322/* drv_callbacks.c (TODO: move to somewhere else?) */
323int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
324 const u8 *ie, size_t ielen, int reassoc);
325void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
326void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
Dmitry Shmidtf8623282013-02-20 14:34:59 -0800327void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
328 const u8 *addr, int reason_code);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800329int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700330 const u8 *bssid, const u8 *ie, size_t ie_len,
331 int ssi_signal);
332void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
333 int offset);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700334
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800335const struct hostapd_eap_user *
336hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
337 size_t identity_len, int phase2);
338
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700339#endif /* HOSTAPD_H */