]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/ap/hostapd.h
Use generic driver event notification for AP mode assoc/disassoc
[thirdparty/hostap.git] / src / ap / hostapd.h
CommitLineData
6fc6879b
JM
1/*
2 * hostapd / Initialization and configuration
45cefa0b 3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
6fc6879b
JM
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
45cefa0b
JM
18#include "common/defs.h"
19
c5121837 20struct wpa_driver_ops;
6fc6879b
JM
21struct wpa_ctrl_dst;
22struct radius_server_data;
f620268f 23struct upnp_wps_device_sm;
9969e5a4 24struct hapd_interfaces;
bf65bc63 25struct hostapd_data;
45cefa0b 26struct sta_info;
a3d4fafa 27struct hostap_sta_driver_data;
2ce86d9d 28struct ieee80211_ht_capabilities;
6fc6879b 29struct full_dynamic_vlan;
6fc6879b 30
fa16028d 31struct hostapd_probereq_cb {
cd7d80f3 32 int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
fa16028d
JM
33 void *ctx;
34};
35
fb7842aa
JM
36#define HOSTAPD_RATE_BASIC 0x00000001
37
38struct hostapd_rate_data {
39 int rate; /* rate in 100 kbps */
40 int flags; /* HOSTAPD_RATE_ flags */
41};
42
2a8b7416
JM
43struct hostapd_frame_info {
44 u32 channel;
45 u32 datarate;
46 u32 ssi_signal;
47};
48
fb7842aa 49
bf65bc63
JM
50struct hostapd_driver_ops {
51 int (*set_ap_wps_ie)(struct hostapd_data *hapd,
14f79386
JM
52 const struct wpabuf *beacon,
53 const struct wpabuf *probe);
c90933d2
JM
54 int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg,
55 size_t len);
45cefa0b
JM
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,
71934751 61 enum wpa_alg alg, const u8 *addr, int key_idx,
45cefa0b
JM
62 int set_tx, const u8 *seq, size_t seq_len,
63 const u8 *key, size_t key_len);
a3d4fafa
JM
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);
4c2ddda4 68 int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta);
010401fe
JM
69 int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname,
70 int enabled);
2f3e0bd4
JM
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);
677449b9
JM
76 int (*set_bss_params)(struct hostapd_data *hapd, int use_protection);
77 int (*set_beacon)(const char *ifname, 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);
36592d31
JM
81 int (*vlan_if_add)(struct hostapd_data *hapd, const char *ifname);
82 int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname);
bdee6fce
JM
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);
2ce86d9d
JM
92 int (*sta_add)(const char *ifname, 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);
bdee6fce 97 int (*sta_remove)(struct hostapd_data *hapd, const u8 *addr);
6d1278e9 98 int (*set_countermeasures)(struct hostapd_data *hapd, int enabled);
bf65bc63
JM
99};
100
6fc6879b
JM
101/**
102 * struct hostapd_data - hostapd per-BSS data structure
103 */
104struct 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 */
2991469c
JM
114#define STA_HASH_SIZE 256
115#define STA_HASH(sta) (sta[5])
6fc6879b
JM
116 struct sta_info *sta_hash[STA_HASH_SIZE];
117
2991469c
JM
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.
6fc6879b 122 */
2991469c
JM
123#define AID_WORDS ((2008 + 31) / 32)
124 u32 sta_aid[AID_WORDS];
6fc6879b 125
c5121837 126 const struct wpa_driver_ops *driver;
6fc6879b 127 void *drv_priv;
bf65bc63 128 struct hostapd_driver_ops drv;
6fc6879b 129
d24df7c3
JM
130 void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
131 struct sta_info *sta, int reassoc);
132
4f760fcc
JM
133 void *msg_ctx; /* ctx for wpa_msg() calls */
134
6fc6879b 135 struct radius_client_data *radius;
6fc6879b
JM
136 u32 acct_session_id_hi, acct_session_id_lo;
137
138 struct iapp_data *iapp;
139
6fc6879b
JM
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;
ad08c363
JM
165 struct wps_context *wps;
166
167#ifdef CONFIG_WPS
14f79386
JM
168 struct wpabuf *wps_beacon_ie;
169 struct wpabuf *wps_probe_resp_ie;
3b2cf800 170 unsigned int ap_pin_failures;
f620268f 171 struct upnp_wps_device_sm *wps_upnp;
ad08c363 172#endif /* CONFIG_WPS */
fa16028d
JM
173
174 struct hostapd_probereq_cb *probereq_cb;
175 size_t num_probereq_cb;
6fc6879b
JM
176};
177
178
6fc6879b
JM
179/**
180 * struct hostapd_iface - hostapd per-interface data structure
181 */
182struct hostapd_iface {
9969e5a4 183 struct hapd_interfaces *interfaces;
0f2b2c19 184 void *owner;
32da61d9 185 int (*reload_config)(struct hostapd_iface *iface);
41d719d6 186 struct hostapd_config * (*config_read_cb)(const char *config_fname);
6fc6879b
JM
187 char *config_fname;
188 struct hostapd_config *conf;
189
6fc6879b
JM
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;
6fc6879b
JM
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
de9289c8
JM
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
edd360e1 232 u16 ht_op_mode;
ad1e68e6 233 void (*scan_cb)(struct hostapd_iface *iface);
70db2ab3
JM
234
235 int (*ctrl_iface_init)(struct hostapd_data *hapd);
236 void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
1b56c26c
JM
237
238 int (*for_each_interface)(struct hapd_interfaces *interfaces,
239 int (*cb)(struct hostapd_iface *iface,
240 void *ctx), void *ctx);
6fc6879b
JM
241};
242
a4f21109 243/* hostapd.c */
ad08c363 244int hostapd_reload_config(struct hostapd_iface *iface);
b6a7859d
JM
245struct hostapd_data *
246hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
247 struct hostapd_config *conf,
248 struct hostapd_bss_config *bss);
5c333467 249int hostapd_setup_interface(struct hostapd_iface *iface);
ad1e68e6 250int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
5c333467 251void hostapd_interface_deinit(struct hostapd_iface *iface);
f7c47833 252void hostapd_interface_free(struct hostapd_iface *iface);
a4f21109
JM
253void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
254 int reassoc);
5c333467 255
a4f21109 256/* utils.c */
fa16028d 257int hostapd_register_probereq_cb(struct hostapd_data *hapd,
cd7d80f3
JM
258 int (*cb)(void *ctx, const u8 *sa,
259 const u8 *ie, size_t ie_len),
fa16028d 260 void *ctx);
0aef3ec8 261void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
fa16028d 262
1d041bec
JM
263/* drv_callbacks.c (TODO: move to somewhere else?) */
264int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
265 const u8 *ie, size_t ielen);
266void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
267
6fc6879b 268#endif /* HOSTAPD_H */