]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/ap/ap_drv_ops.c
P2P: Extend P2P manager functionality to work with driver MLME
[thirdparty/hostap.git] / src / ap / ap_drv_ops.c
CommitLineData
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
4c2ddda4
JM
29static int hostapd_sta_flags_to_drv(int flags)
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
b3db190f 44static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
bf65bc63 45{
0e2e565a 46 struct wpabuf *beacon, *proberesp, *assocresp = NULL;
b3db190f
JM
47 int ret;
48
14f79386
JM
49 if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
50 return 0;
b3db190f
JM
51
52 beacon = hapd->wps_beacon_ie;
53 proberesp = hapd->wps_probe_resp_ie;
54
c2af2afb
JM
55#ifdef CONFIG_P2P
56 if (hapd->wps_beacon_ie == NULL && hapd->p2p_beacon_ie == NULL)
57 beacon = NULL;
58 else {
59 beacon = wpabuf_alloc((hapd->wps_beacon_ie ?
60 wpabuf_len(hapd->wps_beacon_ie) : 0) +
61 (hapd->p2p_beacon_ie ?
62 wpabuf_len(hapd->p2p_beacon_ie) : 0));
63 if (beacon == NULL)
64 return -1;
65 if (hapd->wps_beacon_ie)
66 wpabuf_put_buf(beacon, hapd->wps_beacon_ie);
67 if (hapd->p2p_beacon_ie)
68 wpabuf_put_buf(beacon, hapd->p2p_beacon_ie);
69 }
70
71 if (hapd->wps_probe_resp_ie == NULL && hapd->p2p_probe_resp_ie == NULL)
72 proberesp = NULL;
73 else {
74 proberesp = wpabuf_alloc(
75 (hapd->wps_probe_resp_ie ?
76 wpabuf_len(hapd->wps_probe_resp_ie) : 0) +
77 (hapd->p2p_probe_resp_ie ?
78 wpabuf_len(hapd->p2p_probe_resp_ie) : 0));
79 if (proberesp == NULL) {
80 wpabuf_free(beacon);
81 return -1;
82 }
83 if (hapd->wps_probe_resp_ie)
84 wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie);
85 if (hapd->p2p_probe_resp_ie)
86 wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie);
87 }
88#endif /* CONFIG_P2P */
89
dce044cc
JM
90#ifdef CONFIG_P2P_MANAGER
91 if (hapd->conf->p2p & P2P_MANAGE) {
92 struct wpabuf *a;
93
94 a = wpabuf_alloc(100 + (beacon ? wpabuf_len(beacon) : 0));
95 if (a) {
96 u8 *start, *p;
97 if (beacon)
98 wpabuf_put_buf(a, beacon);
99 if (beacon != hapd->wps_beacon_ie)
100 wpabuf_free(beacon);
101 start = wpabuf_put(a, 0);
102 p = hostapd_eid_p2p_manage(hapd, start);
103 wpabuf_put(a, p - start);
104 beacon = a;
105 }
106
107 a = wpabuf_alloc(100 + (proberesp ? wpabuf_len(proberesp) :
108 0));
109 if (a) {
110 u8 *start, *p;
111 if (proberesp)
112 wpabuf_put_buf(a, proberesp);
113 if (proberesp != hapd->wps_probe_resp_ie)
114 wpabuf_free(proberesp);
115 start = wpabuf_put(a, 0);
116 p = hostapd_eid_p2p_manage(hapd, start);
117 wpabuf_put(a, p - start);
118 proberesp = a;
119 }
120 }
121#endif /* CONFIG_P2P_MANAGER */
122
0e2e565a
JM
123#ifdef CONFIG_WPS2
124 if (hapd->conf->wps_state)
125 assocresp = wps_build_assoc_resp_ie();
126#endif /* CONFIG_WPS2 */
127
dce044cc
JM
128#ifdef CONFIG_P2P_MANAGER
129 if (hapd->conf->p2p & P2P_MANAGE) {
130 struct wpabuf *a;
131 a = wpabuf_alloc(100 + (assocresp ? wpabuf_len(assocresp) :
132 0));
133 if (a) {
134 u8 *start, *p;
135 start = wpabuf_put(a, 0);
136 p = hostapd_eid_p2p_manage(hapd, start);
137 wpabuf_put(a, p - start);
138 if (assocresp) {
139 wpabuf_put_buf(a, assocresp);
140 wpabuf_free(assocresp);
141 }
142 assocresp = a;
143 }
144 }
145#endif /* CONFIG_P2P_MANAGER */
146
0e2e565a
JM
147 ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
148 assocresp);
b3db190f 149
dce044cc
JM
150 if (beacon != hapd->wps_beacon_ie)
151 wpabuf_free(beacon);
152 if (proberesp != hapd->wps_probe_resp_ie)
153 wpabuf_free(proberesp);
0e2e565a 154 wpabuf_free(assocresp);
c2af2afb 155
b3db190f 156 return ret;
bf65bc63
JM
157}
158
159
c90933d2
JM
160static int hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg,
161 size_t len)
162{
163 if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
164 return 0;
165 return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
166}
167
168
45cefa0b
JM
169static int hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr,
170 const u8 *data, size_t data_len, int encrypt)
171{
172 if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
173 return 0;
174 return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
175 data_len, encrypt,
176 hapd->own_addr);
177}
178
179
180static int hostapd_set_authorized(struct hostapd_data *hapd,
181 struct sta_info *sta, int authorized)
182{
183 if (authorized) {
184 return hostapd_sta_set_flags(hapd, sta->addr,
185 hostapd_sta_flags_to_drv(
186 sta->flags),
187 WPA_STA_AUTHORIZED, ~0);
188 }
189
190 return hostapd_sta_set_flags(hapd, sta->addr,
191 hostapd_sta_flags_to_drv(sta->flags),
192 0, ~WPA_STA_AUTHORIZED);
193}
194
195
196static int hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
71934751 197 enum wpa_alg alg, const u8 *addr, int key_idx,
45cefa0b
JM
198 int set_tx, const u8 *seq, size_t seq_len,
199 const u8 *key, size_t key_len)
200{
201 if (hapd->driver == NULL || hapd->driver->set_key == NULL)
202 return 0;
203 return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
204 key_idx, set_tx, seq, seq_len, key,
205 key_len);
206}
207
208
a3d4fafa
JM
209static int hostapd_read_sta_data(struct hostapd_data *hapd,
210 struct hostap_sta_driver_data *data,
211 const u8 *addr)
212{
213 if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
214 return -1;
215 return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
216}
217
218
219static int hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
220{
221 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
222 return 0;
223 return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
224}
225
226
4c2ddda4
JM
227static int hostapd_set_sta_flags(struct hostapd_data *hapd,
228 struct sta_info *sta)
229{
230 int set_flags, total_flags, flags_and, flags_or;
231 total_flags = hostapd_sta_flags_to_drv(sta->flags);
232 set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
ef580012
JM
233 if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
234 sta->auth_alg == WLAN_AUTH_FT) &&
4c2ddda4
JM
235 sta->flags & WLAN_STA_AUTHORIZED)
236 set_flags |= WPA_STA_AUTHORIZED;
237 flags_or = total_flags & set_flags;
238 flags_and = total_flags | ~set_flags;
239 return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
240 flags_or, flags_and);
241}
242
243
010401fe
JM
244static int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd,
245 const char *ifname, int enabled)
246{
247 struct wpa_bss_params params;
248 os_memset(&params, 0, sizeof(params));
249 params.ifname = ifname;
250 params.enabled = enabled;
251 if (enabled) {
252 params.wpa = hapd->conf->wpa;
253 params.ieee802_1x = hapd->conf->ieee802_1x;
254 params.wpa_group = hapd->conf->wpa_group;
255 params.wpa_pairwise = hapd->conf->wpa_pairwise;
256 params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
257 params.rsn_preauth = hapd->conf->rsn_preauth;
258 }
259 return hostapd_set_ieee8021x(hapd, &params);
260}
261
262
2f3e0bd4
JM
263static int hostapd_set_radius_acl_auth(struct hostapd_data *hapd,
264 const u8 *mac, int accepted,
265 u32 session_timeout)
266{
267 if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
268 return 0;
269 return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
270 session_timeout);
271}
272
273
274static int hostapd_set_radius_acl_expire(struct hostapd_data *hapd,
275 const u8 *mac)
276{
277 if (hapd->driver == NULL ||
278 hapd->driver->set_radius_acl_expire == NULL)
279 return 0;
280 return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
281}
282
283
677449b9
JM
284static int hostapd_set_bss_params(struct hostapd_data *hapd,
285 int use_protection)
286{
287 int ret = 0;
288 int preamble;
289#ifdef CONFIG_IEEE80211N
290 u8 buf[60], *ht_capab, *ht_oper, *pos;
291
292 pos = buf;
293 ht_capab = pos;
294 pos = hostapd_eid_ht_capabilities(hapd, pos);
295 ht_oper = pos;
296 pos = hostapd_eid_ht_operation(hapd, pos);
297 if (pos > ht_oper && ht_oper > ht_capab &&
d3e3a205 298 hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
677449b9
JM
299 ht_oper + 2, ht_oper[1])) {
300 wpa_printf(MSG_ERROR, "Could not set HT capabilities "
301 "for kernel driver");
302 ret = -1;
303 }
304
305#endif /* CONFIG_IEEE80211N */
306
307 if (hostapd_set_cts_protect(hapd, use_protection)) {
308 wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
309 "driver");
310 ret = -1;
311 }
312
313 if (hapd->iface->current_mode &&
314 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
315 hostapd_set_short_slot_time(hapd,
316 hapd->iface->num_sta_no_short_slot_time
317 > 0 ? 0 : 1)) {
318 wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
319 "in kernel driver");
320 ret = -1;
321 }
322
323 if (hapd->iface->num_sta_no_short_preamble == 0 &&
324 hapd->iconf->preamble == SHORT_PREAMBLE)
325 preamble = SHORT_PREAMBLE;
326 else
327 preamble = LONG_PREAMBLE;
328 if (hostapd_set_preamble(hapd, preamble)) {
329 wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
330 "driver");
331 ret = -1;
332 }
333
334 return ret;
335}
336
337
8b897f5a 338static int hostapd_set_beacon(struct hostapd_data *hapd,
677449b9
JM
339 const u8 *head, size_t head_len,
340 const u8 *tail, size_t tail_len, int dtim_period,
341 int beacon_int)
342{
343 if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
344 return 0;
8b897f5a 345 return hapd->driver->set_beacon(hapd->drv_priv,
677449b9
JM
346 head, head_len, tail, tail_len,
347 dtim_period, beacon_int);
348}
349
350
36592d31
JM
351static int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
352{
f3585c8a
JM
353 char force_ifname[IFNAMSIZ];
354 u8 if_addr[ETH_ALEN];
355 return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, NULL, NULL, NULL,
356 force_ifname, if_addr);
36592d31
JM
357}
358
359static int hostapd_vlan_if_remove(struct hostapd_data *hapd,
360 const char *ifname)
361{
362 return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
363}
364
365
bdee6fce
JM
366static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr,
367 int aid, int val)
368{
369 if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
370 return 0;
371 return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val);
372}
373
374
375static int hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
376 const u8 *addr, int vlan_id)
377{
378 if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
379 return 0;
380 return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
381 vlan_id);
382}
383
384
385static int hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
386{
387 if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
388 return 0;
389 return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
390}
391
392
393static int hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr,
394 int reason)
395{
396 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
397 return 0;
398 return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
399 reason);
400}
401
402
403static int hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr,
404 int reason)
405{
406 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
407 return 0;
408 return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
409 reason);
410}
411
412
62847751 413static int hostapd_sta_add(struct hostapd_data *hapd,
2ce86d9d
JM
414 const u8 *addr, u16 aid, u16 capability,
415 const u8 *supp_rates, size_t supp_rates_len,
416 u16 listen_interval,
417 const struct ieee80211_ht_capabilities *ht_capab)
418{
419 struct hostapd_sta_add_params params;
420
421 if (hapd->driver == NULL)
422 return 0;
423 if (hapd->driver->sta_add == NULL)
424 return 0;
425
426 os_memset(&params, 0, sizeof(params));
427 params.addr = addr;
428 params.aid = aid;
429 params.capability = capability;
430 params.supp_rates = supp_rates;
431 params.supp_rates_len = supp_rates_len;
432 params.listen_interval = listen_interval;
433 params.ht_capabilities = ht_capab;
62847751 434 return hapd->driver->sta_add(hapd->drv_priv, &params);
2ce86d9d
JM
435}
436
437
bdee6fce
JM
438static int hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
439{
440 if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
441 return 0;
442 return hapd->driver->sta_remove(hapd->drv_priv, addr);
443}
444
445
6d1278e9
JM
446static int hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
447{
448 if (hapd->driver == NULL ||
449 hapd->driver->hapd_set_countermeasures == NULL)
450 return 0;
451 return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
452}
453
454
bf65bc63
JM
455void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
456{
457 ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
c90933d2 458 ops->send_mgmt_frame = hostapd_send_mgmt_frame;
45cefa0b
JM
459 ops->send_eapol = hostapd_send_eapol;
460 ops->set_authorized = hostapd_set_authorized;
461 ops->set_key = hostapd_set_key;
a3d4fafa
JM
462 ops->read_sta_data = hostapd_read_sta_data;
463 ops->sta_clear_stats = hostapd_sta_clear_stats;
4c2ddda4 464 ops->set_sta_flags = hostapd_set_sta_flags;
010401fe 465 ops->set_drv_ieee8021x = hostapd_set_drv_ieee8021x;
2f3e0bd4
JM
466 ops->set_radius_acl_auth = hostapd_set_radius_acl_auth;
467 ops->set_radius_acl_expire = hostapd_set_radius_acl_expire;
677449b9
JM
468 ops->set_bss_params = hostapd_set_bss_params;
469 ops->set_beacon = hostapd_set_beacon;
36592d31
JM
470 ops->vlan_if_add = hostapd_vlan_if_add;
471 ops->vlan_if_remove = hostapd_vlan_if_remove;
bdee6fce
JM
472 ops->set_wds_sta = hostapd_set_wds_sta;
473 ops->set_sta_vlan = hostapd_set_sta_vlan;
474 ops->get_inact_sec = hostapd_get_inact_sec;
475 ops->sta_deauth = hostapd_sta_deauth;
476 ops->sta_disassoc = hostapd_sta_disassoc;
2ce86d9d 477 ops->sta_add = hostapd_sta_add;
bdee6fce 478 ops->sta_remove = hostapd_sta_remove;
6d1278e9 479 ops->set_countermeasures = hostapd_set_countermeasures;
bf65bc63 480}
8b06c1ed
JM
481
482
483int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
484{
485 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
486 return 0;
d5dd016a 487 return hapd->driver->set_privacy(hapd->drv_priv, enabled);
8b06c1ed
JM
488}
489
490
491int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
492 size_t elem_len)
493{
494 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
495 return 0;
aa484516 496 return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
8b06c1ed
JM
497}
498
499
500int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
501{
502 if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
503 return 0;
8709de1a 504 return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
8b06c1ed
JM
505}
506
507
508int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
509{
510 if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
511 return 0;
8709de1a 512 return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
8b06c1ed
JM
513}
514
515
516int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
a2e40bb6 517 const char *ifname, const u8 *addr, void *bss_ctx,
f3585c8a 518 void **drv_priv, char *force_ifname, u8 *if_addr)
8b06c1ed
JM
519{
520 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
521 return -1;
7ab68865 522 return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
f3585c8a 523 bss_ctx, drv_priv, force_ifname, if_addr);
8b06c1ed
JM
524}
525
526
527int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
528 const char *ifname)
529{
530 if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
531 return -1;
532 return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
533}
6e6e8c31
JM
534
535
536int hostapd_set_ieee8021x(struct hostapd_data *hapd,
537 struct wpa_bss_params *params)
538{
539 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
540 return 0;
541 return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
542}
543
544
545int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
546 const u8 *addr, int idx, u8 *seq)
547{
548 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
549 return 0;
550 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
551 seq);
552}
553
554
555int hostapd_flush(struct hostapd_data *hapd)
556{
557 if (hapd->driver == NULL || hapd->driver->flush == NULL)
558 return 0;
559 return hapd->driver->flush(hapd->drv_priv);
560}
561
562
563int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
564 int channel, int ht_enabled, int sec_channel_offset)
565{
566 struct hostapd_freq_params data;
567 if (hapd->driver == NULL)
568 return 0;
569 if (hapd->driver->set_freq == NULL)
570 return 0;
571 os_memset(&data, 0, sizeof(data));
572 data.mode = mode;
573 data.freq = freq;
574 data.channel = channel;
575 data.ht_enabled = ht_enabled;
576 data.sec_channel_offset = sec_channel_offset;
577 return hapd->driver->set_freq(hapd->drv_priv, &data);
578}
579
580int hostapd_set_rts(struct hostapd_data *hapd, int rts)
581{
582 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
583 return 0;
584 return hapd->driver->set_rts(hapd->drv_priv, rts);
585}
586
587
588int hostapd_set_frag(struct hostapd_data *hapd, int frag)
589{
590 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
591 return 0;
592 return hapd->driver->set_frag(hapd->drv_priv, frag);
593}
594
595
596int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
597 int total_flags, int flags_or, int flags_and)
598{
599 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
600 return 0;
3234cba4 601 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
6e6e8c31
JM
602 flags_or, flags_and);
603}
604
605
606int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
607 int *basic_rates, int mode)
608{
609 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
610 return 0;
611 return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
612 basic_rates, mode);
613}
614
615
616int hostapd_set_country(struct hostapd_data *hapd, const char *country)
617{
618 if (hapd->driver == NULL ||
619 hapd->driver->set_country == NULL)
620 return 0;
621 return hapd->driver->set_country(hapd->drv_priv, country);
622}
623
624
625int hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
626{
627 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
628 return 0;
629 return hapd->driver->set_cts_protect(hapd->drv_priv, value);
630}
631
632
633int hostapd_set_preamble(struct hostapd_data *hapd, int value)
634{
635 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
636 return 0;
637 return hapd->driver->set_preamble(hapd->drv_priv, value);
638}
639
640
641int hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
642{
643 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
644 return 0;
645 return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
646}
647
648
649int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
650 int cw_min, int cw_max, int burst_time)
651{
652 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
653 return 0;
654 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
655 cw_min, cw_max, burst_time);
656}
657
658
659int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
660 const u8 *mask)
661{
662 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
663 return 1;
664 return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
665}
666
667
668struct hostapd_hw_modes *
669hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
670 u16 *flags)
671{
672 if (hapd->driver == NULL ||
673 hapd->driver->get_hw_feature_data == NULL)
674 return NULL;
675 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
676 flags);
677}
678
679
680int hostapd_driver_commit(struct hostapd_data *hapd)
681{
682 if (hapd->driver == NULL || hapd->driver->commit == NULL)
683 return 0;
684 return hapd->driver->commit(hapd->drv_priv);
685}
686
687
d3e3a205 688int hostapd_set_ht_params(struct hostapd_data *hapd,
6e6e8c31
JM
689 const u8 *ht_capab, size_t ht_capab_len,
690 const u8 *ht_oper, size_t ht_oper_len)
691{
692 if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
693 ht_capab == NULL || ht_oper == NULL)
694 return 0;
d3e3a205
JM
695 return hapd->driver->set_ht_params(hapd->drv_priv,
696 ht_capab, ht_capab_len,
697 ht_oper, ht_oper_len);
6e6e8c31
JM
698}
699
700
701int hostapd_drv_none(struct hostapd_data *hapd)
702{
703 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
704}
705
706
707int hostapd_driver_scan(struct hostapd_data *hapd,
708 struct wpa_driver_scan_params *params)
709{
710 if (hapd->driver && hapd->driver->scan2)
711 return hapd->driver->scan2(hapd->drv_priv, params);
712 return -1;
713}
714
715
716struct wpa_scan_results * hostapd_driver_get_scan_results(
717 struct hostapd_data *hapd)
718{
719 if (hapd->driver && hapd->driver->get_scan_results2)
720 return hapd->driver->get_scan_results2(hapd->drv_priv);
721 return NULL;
722}
aefb53bd
JM
723
724
725int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
726 int duration)
727{
728 if (hapd->driver && hapd->driver->set_noa)
729 return hapd->driver->set_noa(hapd->drv_priv, count, start,
730 duration);
731 return -1;
732}