]>
Commit | Line | Data |
---|---|---|
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 | 20 | struct wpa_driver_ops; |
6fc6879b JM |
21 | struct wpa_ctrl_dst; |
22 | struct radius_server_data; | |
f620268f | 23 | struct upnp_wps_device_sm; |
9969e5a4 | 24 | struct hapd_interfaces; |
bf65bc63 | 25 | struct hostapd_data; |
45cefa0b | 26 | struct sta_info; |
a3d4fafa | 27 | struct hostap_sta_driver_data; |
2ce86d9d | 28 | struct ieee80211_ht_capabilities; |
6fc6879b | 29 | struct full_dynamic_vlan; |
6fc6879b | 30 | |
fa16028d JM |
31 | struct hostapd_probereq_cb { |
32 | void (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len); | |
33 | void *ctx; | |
34 | }; | |
35 | ||
fb7842aa JM |
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 | ||
bf65bc63 JM |
44 | struct hostapd_driver_ops { |
45 | int (*set_ap_wps_ie)(struct hostapd_data *hapd, | |
14f79386 JM |
46 | const struct wpabuf *beacon, |
47 | const struct wpabuf *probe); | |
c90933d2 JM |
48 | int (*send_mgmt_frame)(struct hostapd_data *hapd, const void *msg, |
49 | size_t len); | |
45cefa0b JM |
50 | int (*send_eapol)(struct hostapd_data *hapd, const u8 *addr, |
51 | const u8 *data, size_t data_len, int encrypt); | |
52 | int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta, | |
53 | int authorized); | |
54 | int (*set_key)(const char *ifname, struct hostapd_data *hapd, | |
55 | wpa_alg alg, const u8 *addr, int key_idx, | |
56 | int set_tx, const u8 *seq, size_t seq_len, | |
57 | const u8 *key, size_t key_len); | |
a3d4fafa JM |
58 | int (*read_sta_data)(struct hostapd_data *hapd, |
59 | struct hostap_sta_driver_data *data, | |
60 | const u8 *addr); | |
61 | int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr); | |
4c2ddda4 | 62 | int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta); |
010401fe JM |
63 | int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname, |
64 | int enabled); | |
2f3e0bd4 JM |
65 | int (*set_radius_acl_auth)(struct hostapd_data *hapd, |
66 | const u8 *mac, int accepted, | |
67 | u32 session_timeout); | |
68 | int (*set_radius_acl_expire)(struct hostapd_data *hapd, | |
69 | const u8 *mac); | |
677449b9 JM |
70 | int (*set_bss_params)(struct hostapd_data *hapd, int use_protection); |
71 | int (*set_beacon)(const char *ifname, struct hostapd_data *hapd, | |
72 | const u8 *head, size_t head_len, | |
73 | const u8 *tail, size_t tail_len, int dtim_period, | |
74 | int beacon_int); | |
36592d31 JM |
75 | int (*vlan_if_add)(struct hostapd_data *hapd, const char *ifname); |
76 | int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname); | |
bdee6fce JM |
77 | int (*set_wds_sta)(struct hostapd_data *hapd, const u8 *addr, int aid, |
78 | int val); | |
79 | int (*set_sta_vlan)(const char *ifname, struct hostapd_data *hapd, | |
80 | const u8 *addr, int vlan_id); | |
81 | int (*get_inact_sec)(struct hostapd_data *hapd, const u8 *addr); | |
82 | int (*sta_deauth)(struct hostapd_data *hapd, const u8 *addr, | |
83 | int reason); | |
84 | int (*sta_disassoc)(struct hostapd_data *hapd, const u8 *addr, | |
85 | int reason); | |
2ce86d9d JM |
86 | int (*sta_add)(const char *ifname, struct hostapd_data *hapd, |
87 | const u8 *addr, u16 aid, u16 capability, | |
88 | const u8 *supp_rates, size_t supp_rates_len, | |
89 | u16 listen_interval, | |
90 | const struct ieee80211_ht_capabilities *ht_capab); | |
bdee6fce | 91 | int (*sta_remove)(struct hostapd_data *hapd, const u8 *addr); |
6d1278e9 | 92 | int (*set_countermeasures)(struct hostapd_data *hapd, int enabled); |
bf65bc63 JM |
93 | }; |
94 | ||
6fc6879b JM |
95 | /** |
96 | * struct hostapd_data - hostapd per-BSS data structure | |
97 | */ | |
98 | struct hostapd_data { | |
99 | struct hostapd_iface *iface; | |
100 | struct hostapd_config *iconf; | |
101 | struct hostapd_bss_config *conf; | |
102 | int interface_added; /* virtual interface added for this BSS */ | |
103 | ||
104 | u8 own_addr[ETH_ALEN]; | |
105 | ||
106 | int num_sta; /* number of entries in sta_list */ | |
107 | struct sta_info *sta_list; /* STA info list head */ | |
2991469c JM |
108 | #define STA_HASH_SIZE 256 |
109 | #define STA_HASH(sta) (sta[5]) | |
6fc6879b JM |
110 | struct sta_info *sta_hash[STA_HASH_SIZE]; |
111 | ||
2991469c JM |
112 | /* |
113 | * Bitfield for indicating which AIDs are allocated. Only AID values | |
114 | * 1-2007 are used and as such, the bit at index 0 corresponds to AID | |
115 | * 1. | |
6fc6879b | 116 | */ |
2991469c JM |
117 | #define AID_WORDS ((2008 + 31) / 32) |
118 | u32 sta_aid[AID_WORDS]; | |
6fc6879b | 119 | |
c5121837 | 120 | const struct wpa_driver_ops *driver; |
6fc6879b | 121 | void *drv_priv; |
bf65bc63 | 122 | struct hostapd_driver_ops drv; |
6fc6879b | 123 | |
d24df7c3 JM |
124 | void (*new_assoc_sta_cb)(struct hostapd_data *hapd, |
125 | struct sta_info *sta, int reassoc); | |
126 | ||
4f760fcc JM |
127 | void *msg_ctx; /* ctx for wpa_msg() calls */ |
128 | ||
6fc6879b | 129 | struct radius_client_data *radius; |
6fc6879b JM |
130 | u32 acct_session_id_hi, acct_session_id_lo; |
131 | ||
132 | struct iapp_data *iapp; | |
133 | ||
6fc6879b JM |
134 | struct hostapd_cached_radius_acl *acl_cache; |
135 | struct hostapd_acl_query_data *acl_queries; | |
136 | ||
137 | struct wpa_authenticator *wpa_auth; | |
138 | struct eapol_authenticator *eapol_auth; | |
139 | ||
140 | struct rsn_preauth_interface *preauth_iface; | |
141 | time_t michael_mic_failure; | |
142 | int michael_mic_failures; | |
143 | int tkip_countermeasures; | |
144 | ||
145 | int ctrl_sock; | |
146 | struct wpa_ctrl_dst *ctrl_dst; | |
147 | ||
148 | void *ssl_ctx; | |
149 | void *eap_sim_db_priv; | |
150 | struct radius_server_data *radius_srv; | |
151 | ||
152 | int parameter_set_count; | |
153 | ||
154 | #ifdef CONFIG_FULL_DYNAMIC_VLAN | |
155 | struct full_dynamic_vlan *full_dynamic_vlan; | |
156 | #endif /* CONFIG_FULL_DYNAMIC_VLAN */ | |
157 | ||
158 | struct l2_packet_data *l2; | |
ad08c363 JM |
159 | struct wps_context *wps; |
160 | ||
161 | #ifdef CONFIG_WPS | |
14f79386 JM |
162 | struct wpabuf *wps_beacon_ie; |
163 | struct wpabuf *wps_probe_resp_ie; | |
3b2cf800 | 164 | unsigned int ap_pin_failures; |
f620268f | 165 | struct upnp_wps_device_sm *wps_upnp; |
ad08c363 | 166 | #endif /* CONFIG_WPS */ |
fa16028d JM |
167 | |
168 | struct hostapd_probereq_cb *probereq_cb; | |
169 | size_t num_probereq_cb; | |
6fc6879b JM |
170 | }; |
171 | ||
172 | ||
6fc6879b JM |
173 | /** |
174 | * struct hostapd_iface - hostapd per-interface data structure | |
175 | */ | |
176 | struct hostapd_iface { | |
9969e5a4 | 177 | struct hapd_interfaces *interfaces; |
0f2b2c19 | 178 | void *owner; |
32da61d9 | 179 | int (*reload_config)(struct hostapd_iface *iface); |
41d719d6 | 180 | struct hostapd_config * (*config_read_cb)(const char *config_fname); |
6fc6879b JM |
181 | char *config_fname; |
182 | struct hostapd_config *conf; | |
183 | ||
6fc6879b JM |
184 | size_t num_bss; |
185 | struct hostapd_data **bss; | |
186 | ||
187 | int num_ap; /* number of entries in ap_list */ | |
188 | struct ap_info *ap_list; /* AP info list head */ | |
189 | struct ap_info *ap_hash[STA_HASH_SIZE]; | |
190 | struct ap_info *ap_iter_list; | |
191 | ||
192 | struct hostapd_hw_modes *hw_features; | |
193 | int num_hw_features; | |
194 | struct hostapd_hw_modes *current_mode; | |
195 | /* Rates that are currently used (i.e., filtered copy of | |
196 | * current_mode->channels */ | |
197 | int num_rates; | |
198 | struct hostapd_rate_data *current_rates; | |
6fc6879b JM |
199 | |
200 | u16 hw_flags; | |
201 | ||
202 | /* Number of associated Non-ERP stations (i.e., stations using 802.11b | |
203 | * in 802.11g BSS) */ | |
204 | int num_sta_non_erp; | |
205 | ||
206 | /* Number of associated stations that do not support Short Slot Time */ | |
207 | int num_sta_no_short_slot_time; | |
208 | ||
209 | /* Number of associated stations that do not support Short Preamble */ | |
210 | int num_sta_no_short_preamble; | |
211 | ||
212 | int olbc; /* Overlapping Legacy BSS Condition */ | |
213 | ||
de9289c8 JM |
214 | /* Number of HT associated stations that do not support greenfield */ |
215 | int num_sta_ht_no_gf; | |
216 | ||
217 | /* Number of associated non-HT stations */ | |
218 | int num_sta_no_ht; | |
219 | ||
220 | /* Number of HT associated stations 20 MHz */ | |
221 | int num_sta_ht_20mhz; | |
222 | ||
223 | /* Overlapping BSS information */ | |
224 | int olbc_ht; | |
225 | ||
edd360e1 | 226 | u16 ht_op_mode; |
ad1e68e6 | 227 | void (*scan_cb)(struct hostapd_iface *iface); |
70db2ab3 JM |
228 | |
229 | int (*ctrl_iface_init)(struct hostapd_data *hapd); | |
230 | void (*ctrl_iface_deinit)(struct hostapd_data *hapd); | |
1b56c26c JM |
231 | |
232 | int (*for_each_interface)(struct hapd_interfaces *interfaces, | |
233 | int (*cb)(struct hostapd_iface *iface, | |
234 | void *ctx), void *ctx); | |
6fc6879b JM |
235 | }; |
236 | ||
a4f21109 | 237 | /* hostapd.c */ |
ad08c363 | 238 | int hostapd_reload_config(struct hostapd_iface *iface); |
b6a7859d JM |
239 | struct hostapd_data * |
240 | hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, | |
241 | struct hostapd_config *conf, | |
242 | struct hostapd_bss_config *bss); | |
5c333467 | 243 | int hostapd_setup_interface(struct hostapd_iface *iface); |
ad1e68e6 | 244 | int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err); |
5c333467 | 245 | void hostapd_interface_deinit(struct hostapd_iface *iface); |
a4f21109 JM |
246 | void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, |
247 | int reassoc); | |
5c333467 | 248 | |
a4f21109 | 249 | /* utils.c */ |
fa16028d JM |
250 | int hostapd_register_probereq_cb(struct hostapd_data *hapd, |
251 | void (*cb)(void *ctx, const u8 *sa, | |
252 | const u8 *ie, size_t ie_len), | |
253 | void *ctx); | |
0aef3ec8 | 254 | void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr); |
fa16028d | 255 | |
6fc6879b | 256 | #endif /* HOSTAPD_H */ |