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