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