]>
Commit | Line | Data |
---|---|---|
bf65bc63 JM |
1 | /* |
2 | * hostapd - Driver operations | |
ef580012 | 3 | * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> |
bf65bc63 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 | ||
8b06c1ed | 15 | #include "utils/includes.h" |
bf65bc63 | 16 | |
8b06c1ed | 17 | #include "utils/common.h" |
6e6e8c31 | 18 | #include "drivers/driver.h" |
ef580012 | 19 | #include "common/ieee802_11_defs.h" |
0e2e565a | 20 | #include "wps/wps.h" |
8b06c1ed JM |
21 | #include "hostapd.h" |
22 | #include "ieee802_11.h" | |
23 | #include "sta_info.h" | |
24 | #include "ap_config.h" | |
dce044cc | 25 | #include "p2p_hostapd.h" |
a4f21109 | 26 | #include "ap_drv_ops.h" |
bf65bc63 JM |
27 | |
28 | ||
4378fc14 | 29 | u32 hostapd_sta_flags_to_drv(u32 flags) |
4c2ddda4 JM |
30 | { |
31 | int res = 0; | |
32 | if (flags & WLAN_STA_AUTHORIZED) | |
33 | res |= WPA_STA_AUTHORIZED; | |
34 | if (flags & WLAN_STA_WMM) | |
35 | res |= WPA_STA_WMM; | |
36 | if (flags & WLAN_STA_SHORT_PREAMBLE) | |
37 | res |= WPA_STA_SHORT_PREAMBLE; | |
38 | if (flags & WLAN_STA_MFP) | |
39 | res |= WPA_STA_MFP; | |
40 | return res; | |
41 | } | |
42 | ||
43 | ||
fb91db56 | 44 | int hostapd_build_ap_extra_ies(struct hostapd_data *hapd, |
c2ff13c5 JM |
45 | struct wpabuf **beacon_ret, |
46 | struct wpabuf **proberesp_ret, | |
47 | struct wpabuf **assocresp_ret) | |
bf65bc63 | 48 | { |
c2ff13c5 | 49 | struct wpabuf *beacon = NULL, *proberesp = NULL, *assocresp = NULL; |
a194b06c | 50 | u8 buf[100], *pos; |
c2ff13c5 JM |
51 | |
52 | *beacon_ret = *proberesp_ret = *assocresp_ret = NULL; | |
53 | ||
a194b06c JM |
54 | pos = buf; |
55 | pos = hostapd_eid_ext_capab(hapd, pos); | |
56 | if (pos != buf) { | |
57 | if (wpabuf_resize(&assocresp, pos - buf) != 0) | |
58 | goto fail; | |
59 | wpabuf_put_data(assocresp, buf, pos - buf); | |
60 | } | |
61 | pos = hostapd_eid_interworking(hapd, pos); | |
c7c178e1 | 62 | pos = hostapd_eid_adv_proto(hapd, pos); |
a194b06c JM |
63 | if (pos != buf) { |
64 | if (wpabuf_resize(&beacon, pos - buf) != 0) | |
65 | goto fail; | |
66 | wpabuf_put_data(beacon, buf, pos - buf); | |
67 | ||
68 | if (wpabuf_resize(&proberesp, pos - buf) != 0) | |
69 | goto fail; | |
70 | wpabuf_put_data(proberesp, buf, pos - buf); | |
71 | } | |
72 | ||
c2ff13c5 JM |
73 | if (hapd->wps_beacon_ie) { |
74 | if (wpabuf_resize(&beacon, wpabuf_len(hapd->wps_beacon_ie)) < | |
75 | 0) | |
76 | goto fail; | |
77 | wpabuf_put_buf(beacon, hapd->wps_beacon_ie); | |
78 | } | |
79 | ||
80 | if (hapd->wps_probe_resp_ie) { | |
81 | if (wpabuf_resize(&proberesp, | |
82 | wpabuf_len(hapd->wps_probe_resp_ie)) < 0) | |
83 | goto fail; | |
84 | wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie); | |
85 | } | |
b3db190f | 86 | |
c2af2afb | 87 | #ifdef CONFIG_P2P |
c2ff13c5 JM |
88 | if (hapd->p2p_beacon_ie) { |
89 | if (wpabuf_resize(&beacon, wpabuf_len(hapd->p2p_beacon_ie)) < | |
90 | 0) | |
91 | goto fail; | |
92 | wpabuf_put_buf(beacon, hapd->p2p_beacon_ie); | |
c2af2afb JM |
93 | } |
94 | ||
c2ff13c5 JM |
95 | if (hapd->p2p_probe_resp_ie) { |
96 | if (wpabuf_resize(&beacon, wpabuf_len(hapd->p2p_probe_resp_ie)) | |
97 | < 0) | |
98 | goto fail; | |
99 | wpabuf_put_buf(beacon, hapd->p2p_probe_resp_ie); | |
c2af2afb JM |
100 | } |
101 | #endif /* CONFIG_P2P */ | |
102 | ||
dce044cc JM |
103 | #ifdef CONFIG_P2P_MANAGER |
104 | if (hapd->conf->p2p & P2P_MANAGE) { | |
c2ff13c5 | 105 | if (wpabuf_resize(&beacon, 100) == 0) { |
dce044cc | 106 | u8 *start, *p; |
c2ff13c5 | 107 | start = wpabuf_put(beacon, 0); |
dce044cc | 108 | p = hostapd_eid_p2p_manage(hapd, start); |
c2ff13c5 | 109 | wpabuf_put(beacon, p - start); |
dce044cc JM |
110 | } |
111 | ||
c2ff13c5 | 112 | if (wpabuf_resize(&proberesp, 100) == 0) { |
dce044cc | 113 | u8 *start, *p; |
c2ff13c5 | 114 | start = wpabuf_put(proberesp, 0); |
dce044cc | 115 | p = hostapd_eid_p2p_manage(hapd, start); |
c2ff13c5 | 116 | wpabuf_put(proberesp, p - start); |
dce044cc JM |
117 | } |
118 | } | |
119 | #endif /* CONFIG_P2P_MANAGER */ | |
120 | ||
0e2e565a | 121 | #ifdef CONFIG_WPS2 |
c2ff13c5 JM |
122 | if (hapd->conf->wps_state) { |
123 | struct wpabuf *a = wps_build_assoc_resp_ie(); | |
124 | if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0) | |
125 | wpabuf_put_buf(assocresp, a); | |
126 | wpabuf_free(a); | |
127 | } | |
0e2e565a JM |
128 | #endif /* CONFIG_WPS2 */ |
129 | ||
dce044cc JM |
130 | #ifdef CONFIG_P2P_MANAGER |
131 | if (hapd->conf->p2p & P2P_MANAGE) { | |
c2ff13c5 | 132 | if (wpabuf_resize(&assocresp, 100) == 0) { |
dce044cc | 133 | u8 *start, *p; |
c2ff13c5 | 134 | start = wpabuf_put(assocresp, 0); |
dce044cc | 135 | p = hostapd_eid_p2p_manage(hapd, start); |
c2ff13c5 | 136 | wpabuf_put(assocresp, p - start); |
dce044cc JM |
137 | } |
138 | } | |
139 | #endif /* CONFIG_P2P_MANAGER */ | |
140 | ||
c2ff13c5 JM |
141 | *beacon_ret = beacon; |
142 | *proberesp_ret = proberesp; | |
143 | *assocresp_ret = assocresp; | |
144 | ||
fb91db56 | 145 | return 0; |
c2ff13c5 JM |
146 | |
147 | fail: | |
148 | wpabuf_free(beacon); | |
149 | wpabuf_free(proberesp); | |
150 | wpabuf_free(assocresp); | |
151 | return -1; | |
fb91db56 JM |
152 | } |
153 | ||
b3db190f | 154 | |
c2ff13c5 JM |
155 | void hostapd_free_ap_extra_ies(struct hostapd_data *hapd, |
156 | struct wpabuf *beacon, | |
fb91db56 JM |
157 | struct wpabuf *proberesp, |
158 | struct wpabuf *assocresp) | |
159 | { | |
c2ff13c5 JM |
160 | wpabuf_free(beacon); |
161 | wpabuf_free(proberesp); | |
0e2e565a | 162 | wpabuf_free(assocresp); |
fb91db56 JM |
163 | } |
164 | ||
165 | ||
166 | int hostapd_set_ap_wps_ie(struct hostapd_data *hapd) | |
167 | { | |
168 | struct wpabuf *beacon, *proberesp, *assocresp; | |
169 | int ret; | |
170 | ||
171 | if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL) | |
172 | return 0; | |
173 | ||
174 | if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < | |
175 | 0) | |
176 | return -1; | |
177 | ||
178 | ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp, | |
179 | assocresp); | |
180 | ||
181 | hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); | |
c2af2afb | 182 | |
b3db190f | 183 | return ret; |
bf65bc63 JM |
184 | } |
185 | ||
186 | ||
0e8a96a9 JM |
187 | int hostapd_set_authorized(struct hostapd_data *hapd, |
188 | struct sta_info *sta, int authorized) | |
45cefa0b JM |
189 | { |
190 | if (authorized) { | |
191 | return hostapd_sta_set_flags(hapd, sta->addr, | |
192 | hostapd_sta_flags_to_drv( | |
193 | sta->flags), | |
194 | WPA_STA_AUTHORIZED, ~0); | |
195 | } | |
196 | ||
197 | return hostapd_sta_set_flags(hapd, sta->addr, | |
198 | hostapd_sta_flags_to_drv(sta->flags), | |
199 | 0, ~WPA_STA_AUTHORIZED); | |
200 | } | |
201 | ||
202 | ||
0e8a96a9 | 203 | int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta) |
4c2ddda4 JM |
204 | { |
205 | int set_flags, total_flags, flags_and, flags_or; | |
206 | total_flags = hostapd_sta_flags_to_drv(sta->flags); | |
207 | set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP; | |
ef580012 JM |
208 | if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) || |
209 | sta->auth_alg == WLAN_AUTH_FT) && | |
4c2ddda4 JM |
210 | sta->flags & WLAN_STA_AUTHORIZED) |
211 | set_flags |= WPA_STA_AUTHORIZED; | |
212 | flags_or = total_flags & set_flags; | |
213 | flags_and = total_flags | ~set_flags; | |
214 | return hostapd_sta_set_flags(hapd, sta->addr, total_flags, | |
215 | flags_or, flags_and); | |
216 | } | |
217 | ||
218 | ||
0e8a96a9 JM |
219 | int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, |
220 | int enabled) | |
010401fe JM |
221 | { |
222 | struct wpa_bss_params params; | |
223 | os_memset(¶ms, 0, sizeof(params)); | |
224 | params.ifname = ifname; | |
225 | params.enabled = enabled; | |
226 | if (enabled) { | |
227 | params.wpa = hapd->conf->wpa; | |
228 | params.ieee802_1x = hapd->conf->ieee802_1x; | |
229 | params.wpa_group = hapd->conf->wpa_group; | |
230 | params.wpa_pairwise = hapd->conf->wpa_pairwise; | |
231 | params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt; | |
232 | params.rsn_preauth = hapd->conf->rsn_preauth; | |
a1ca0292 MP |
233 | #ifdef CONFIG_IEEE80211W |
234 | params.ieee80211w = hapd->conf->ieee80211w; | |
235 | #endif /* CONFIG_IEEE80211W */ | |
010401fe JM |
236 | } |
237 | return hostapd_set_ieee8021x(hapd, ¶ms); | |
238 | } | |
239 | ||
240 | ||
0e8a96a9 | 241 | int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) |
36592d31 | 242 | { |
f3585c8a JM |
243 | char force_ifname[IFNAMSIZ]; |
244 | u8 if_addr[ETH_ALEN]; | |
e926bcff | 245 | return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr, |
e17a2477 | 246 | NULL, NULL, force_ifname, if_addr, NULL); |
36592d31 JM |
247 | } |
248 | ||
0e8a96a9 JM |
249 | |
250 | int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname) | |
36592d31 JM |
251 | { |
252 | return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname); | |
253 | } | |
254 | ||
255 | ||
0e8a96a9 JM |
256 | int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid, |
257 | int val) | |
bdee6fce | 258 | { |
d38ae2ea FF |
259 | const char *bridge = NULL; |
260 | ||
bdee6fce JM |
261 | if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL) |
262 | return 0; | |
d38ae2ea FF |
263 | if (hapd->conf->wds_bridge[0]) |
264 | bridge = hapd->conf->wds_bridge; | |
265 | else if (hapd->conf->bridge[0]) | |
266 | bridge = hapd->conf->bridge; | |
0e8a96a9 JM |
267 | return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val, |
268 | bridge); | |
bdee6fce JM |
269 | } |
270 | ||
271 | ||
a52eba0f SP |
272 | int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr, |
273 | u16 auth_alg) | |
274 | { | |
275 | if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL) | |
276 | return 0; | |
277 | return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg); | |
278 | } | |
279 | ||
280 | ||
281 | int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr, | |
282 | u16 seq, u16 status, const u8 *ie, size_t len) | |
283 | { | |
284 | if (hapd->driver == NULL || hapd->driver->sta_auth == NULL) | |
285 | return 0; | |
286 | return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr, | |
287 | seq, status, ie, len); | |
288 | } | |
289 | ||
290 | ||
291 | int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr, | |
292 | int reassoc, u16 status, const u8 *ie, size_t len) | |
293 | { | |
294 | if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL) | |
295 | return 0; | |
296 | return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr, | |
297 | reassoc, status, ie, len); | |
298 | } | |
299 | ||
300 | ||
0e8a96a9 JM |
301 | int hostapd_sta_add(struct hostapd_data *hapd, |
302 | const u8 *addr, u16 aid, u16 capability, | |
303 | const u8 *supp_rates, size_t supp_rates_len, | |
304 | u16 listen_interval, | |
d83ab1fe AN |
305 | const struct ieee80211_ht_capabilities *ht_capab, |
306 | u32 flags) | |
2ce86d9d JM |
307 | { |
308 | struct hostapd_sta_add_params params; | |
309 | ||
310 | if (hapd->driver == NULL) | |
311 | return 0; | |
312 | if (hapd->driver->sta_add == NULL) | |
313 | return 0; | |
314 | ||
315 | os_memset(¶ms, 0, sizeof(params)); | |
316 | params.addr = addr; | |
317 | params.aid = aid; | |
318 | params.capability = capability; | |
319 | params.supp_rates = supp_rates; | |
320 | params.supp_rates_len = supp_rates_len; | |
321 | params.listen_interval = listen_interval; | |
322 | params.ht_capabilities = ht_capab; | |
d83ab1fe | 323 | params.flags = hostapd_sta_flags_to_drv(flags); |
62847751 | 324 | return hapd->driver->sta_add(hapd->drv_priv, ¶ms); |
2ce86d9d JM |
325 | } |
326 | ||
327 | ||
a52eba0f SP |
328 | int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr, |
329 | u8 *tspec_ie, size_t tspec_ielen) | |
330 | { | |
331 | if (hapd->driver == NULL || hapd->driver->add_tspec == NULL) | |
332 | return 0; | |
333 | return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie, | |
334 | tspec_ielen); | |
335 | } | |
336 | ||
337 | ||
8b06c1ed JM |
338 | int hostapd_set_privacy(struct hostapd_data *hapd, int enabled) |
339 | { | |
340 | if (hapd->driver == NULL || hapd->driver->set_privacy == NULL) | |
341 | return 0; | |
d5dd016a | 342 | return hapd->driver->set_privacy(hapd->drv_priv, enabled); |
8b06c1ed JM |
343 | } |
344 | ||
345 | ||
346 | int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem, | |
347 | size_t elem_len) | |
348 | { | |
349 | if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL) | |
350 | return 0; | |
aa484516 | 351 | return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len); |
8b06c1ed JM |
352 | } |
353 | ||
354 | ||
355 | int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len) | |
356 | { | |
357 | if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL) | |
358 | return 0; | |
8709de1a | 359 | return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len); |
8b06c1ed JM |
360 | } |
361 | ||
362 | ||
363 | int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len) | |
364 | { | |
365 | if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL) | |
366 | return 0; | |
8709de1a | 367 | return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len); |
8b06c1ed JM |
368 | } |
369 | ||
370 | ||
371 | int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type, | |
a2e40bb6 | 372 | const char *ifname, const u8 *addr, void *bss_ctx, |
e17a2477 JM |
373 | void **drv_priv, char *force_ifname, u8 *if_addr, |
374 | const char *bridge) | |
8b06c1ed JM |
375 | { |
376 | if (hapd->driver == NULL || hapd->driver->if_add == NULL) | |
377 | return -1; | |
7ab68865 | 378 | return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr, |
e17a2477 JM |
379 | bss_ctx, drv_priv, force_ifname, if_addr, |
380 | bridge); | |
8b06c1ed JM |
381 | } |
382 | ||
383 | ||
384 | int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, | |
385 | const char *ifname) | |
386 | { | |
387 | if (hapd->driver == NULL || hapd->driver->if_remove == NULL) | |
388 | return -1; | |
389 | return hapd->driver->if_remove(hapd->drv_priv, type, ifname); | |
390 | } | |
6e6e8c31 JM |
391 | |
392 | ||
393 | int hostapd_set_ieee8021x(struct hostapd_data *hapd, | |
394 | struct wpa_bss_params *params) | |
395 | { | |
396 | if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL) | |
397 | return 0; | |
398 | return hapd->driver->set_ieee8021x(hapd->drv_priv, params); | |
399 | } | |
400 | ||
401 | ||
402 | int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd, | |
403 | const u8 *addr, int idx, u8 *seq) | |
404 | { | |
405 | if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL) | |
406 | return 0; | |
407 | return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx, | |
408 | seq); | |
409 | } | |
410 | ||
411 | ||
412 | int hostapd_flush(struct hostapd_data *hapd) | |
413 | { | |
414 | if (hapd->driver == NULL || hapd->driver->flush == NULL) | |
415 | return 0; | |
416 | return hapd->driver->flush(hapd->drv_priv); | |
417 | } | |
418 | ||
419 | ||
420 | int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, | |
421 | int channel, int ht_enabled, int sec_channel_offset) | |
422 | { | |
423 | struct hostapd_freq_params data; | |
424 | if (hapd->driver == NULL) | |
425 | return 0; | |
426 | if (hapd->driver->set_freq == NULL) | |
427 | return 0; | |
428 | os_memset(&data, 0, sizeof(data)); | |
429 | data.mode = mode; | |
430 | data.freq = freq; | |
431 | data.channel = channel; | |
432 | data.ht_enabled = ht_enabled; | |
433 | data.sec_channel_offset = sec_channel_offset; | |
434 | return hapd->driver->set_freq(hapd->drv_priv, &data); | |
435 | } | |
436 | ||
437 | int hostapd_set_rts(struct hostapd_data *hapd, int rts) | |
438 | { | |
439 | if (hapd->driver == NULL || hapd->driver->set_rts == NULL) | |
440 | return 0; | |
441 | return hapd->driver->set_rts(hapd->drv_priv, rts); | |
442 | } | |
443 | ||
444 | ||
445 | int hostapd_set_frag(struct hostapd_data *hapd, int frag) | |
446 | { | |
447 | if (hapd->driver == NULL || hapd->driver->set_frag == NULL) | |
448 | return 0; | |
449 | return hapd->driver->set_frag(hapd->drv_priv, frag); | |
450 | } | |
451 | ||
452 | ||
453 | int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr, | |
454 | int total_flags, int flags_or, int flags_and) | |
455 | { | |
456 | if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL) | |
457 | return 0; | |
3234cba4 | 458 | return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags, |
6e6e8c31 JM |
459 | flags_or, flags_and); |
460 | } | |
461 | ||
462 | ||
463 | int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates, | |
464 | int *basic_rates, int mode) | |
465 | { | |
466 | if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL) | |
467 | return 0; | |
468 | return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates, | |
469 | basic_rates, mode); | |
470 | } | |
471 | ||
472 | ||
473 | int hostapd_set_country(struct hostapd_data *hapd, const char *country) | |
474 | { | |
475 | if (hapd->driver == NULL || | |
476 | hapd->driver->set_country == NULL) | |
477 | return 0; | |
478 | return hapd->driver->set_country(hapd->drv_priv, country); | |
479 | } | |
480 | ||
481 | ||
6e6e8c31 JM |
482 | int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs, |
483 | int cw_min, int cw_max, int burst_time) | |
484 | { | |
485 | if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL) | |
486 | return 0; | |
487 | return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs, | |
488 | cw_min, cw_max, burst_time); | |
489 | } | |
490 | ||
491 | ||
492 | int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr, | |
493 | const u8 *mask) | |
494 | { | |
495 | if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL) | |
496 | return 1; | |
497 | return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask); | |
498 | } | |
499 | ||
500 | ||
501 | struct hostapd_hw_modes * | |
502 | hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes, | |
503 | u16 *flags) | |
504 | { | |
505 | if (hapd->driver == NULL || | |
506 | hapd->driver->get_hw_feature_data == NULL) | |
507 | return NULL; | |
508 | return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes, | |
509 | flags); | |
510 | } | |
511 | ||
512 | ||
513 | int hostapd_driver_commit(struct hostapd_data *hapd) | |
514 | { | |
515 | if (hapd->driver == NULL || hapd->driver->commit == NULL) | |
516 | return 0; | |
517 | return hapd->driver->commit(hapd->drv_priv); | |
518 | } | |
519 | ||
520 | ||
6e6e8c31 JM |
521 | int hostapd_drv_none(struct hostapd_data *hapd) |
522 | { | |
523 | return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0; | |
524 | } | |
525 | ||
526 | ||
527 | int hostapd_driver_scan(struct hostapd_data *hapd, | |
528 | struct wpa_driver_scan_params *params) | |
529 | { | |
530 | if (hapd->driver && hapd->driver->scan2) | |
531 | return hapd->driver->scan2(hapd->drv_priv, params); | |
532 | return -1; | |
533 | } | |
534 | ||
535 | ||
536 | struct wpa_scan_results * hostapd_driver_get_scan_results( | |
537 | struct hostapd_data *hapd) | |
538 | { | |
539 | if (hapd->driver && hapd->driver->get_scan_results2) | |
540 | return hapd->driver->get_scan_results2(hapd->drv_priv); | |
541 | return NULL; | |
542 | } | |
aefb53bd JM |
543 | |
544 | ||
545 | int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start, | |
546 | int duration) | |
547 | { | |
548 | if (hapd->driver && hapd->driver->set_noa) | |
549 | return hapd->driver->set_noa(hapd->drv_priv, count, start, | |
550 | duration); | |
551 | return -1; | |
552 | } | |
7392f11e JM |
553 | |
554 | ||
555 | int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd, | |
556 | enum wpa_alg alg, const u8 *addr, | |
557 | int key_idx, int set_tx, | |
558 | const u8 *seq, size_t seq_len, | |
559 | const u8 *key, size_t key_len) | |
560 | { | |
561 | if (hapd->driver == NULL || hapd->driver->set_key == NULL) | |
562 | return 0; | |
563 | return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr, | |
564 | key_idx, set_tx, seq, seq_len, key, | |
565 | key_len); | |
566 | } | |
567 | ||
568 | ||
569 | int hostapd_drv_send_mlme(struct hostapd_data *hapd, | |
570 | const void *msg, size_t len) | |
571 | { | |
572 | if (hapd->driver == NULL || hapd->driver->send_mlme == NULL) | |
573 | return 0; | |
574 | return hapd->driver->send_mlme(hapd->drv_priv, msg, len); | |
575 | } | |
576 | ||
577 | ||
578 | int hostapd_drv_sta_deauth(struct hostapd_data *hapd, | |
579 | const u8 *addr, int reason) | |
580 | { | |
581 | if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL) | |
582 | return 0; | |
583 | return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr, | |
584 | reason); | |
585 | } | |
586 | ||
587 | ||
588 | int hostapd_drv_sta_disassoc(struct hostapd_data *hapd, | |
589 | const u8 *addr, int reason) | |
590 | { | |
591 | if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL) | |
592 | return 0; | |
593 | return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr, | |
594 | reason); | |
595 | } |