2 * hostapd - Driver operations
3 * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #include "utils/common.h"
12 #include "common/ieee802_11_defs.h"
13 #include "common/hw_features_common.h"
17 #include "ieee802_11.h"
19 #include "ap_config.h"
20 #include "p2p_hostapd.h"
22 #include "ap_drv_ops.h"
25 u32 hostapd_sta_flags_to_drv(u32 flags)
28 if (flags & WLAN_STA_AUTHORIZED)
29 res |= WPA_STA_AUTHORIZED;
30 if (flags & WLAN_STA_WMM)
32 if (flags & WLAN_STA_SHORT_PREAMBLE)
33 res |= WPA_STA_SHORT_PREAMBLE;
34 if (flags & WLAN_STA_MFP)
40 int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
41 struct wpabuf **beacon_ret,
42 struct wpabuf **proberesp_ret,
43 struct wpabuf **assocresp_ret)
45 struct wpabuf *beacon = NULL, *proberesp = NULL, *assocresp = NULL;
48 *beacon_ret = *proberesp_ret = *assocresp_ret = NULL;
51 pos = hostapd_eid_time_adv(hapd, pos);
53 if (wpabuf_resize(&beacon, pos - buf) != 0)
55 wpabuf_put_data(beacon, buf, pos - buf);
57 pos = hostapd_eid_time_zone(hapd, pos);
59 if (wpabuf_resize(&proberesp, pos - buf) != 0)
61 wpabuf_put_data(proberesp, buf, pos - buf);
65 pos = hostapd_eid_ext_capab(hapd, pos);
67 if (wpabuf_resize(&assocresp, pos - buf) != 0)
69 wpabuf_put_data(assocresp, buf, pos - buf);
71 pos = hostapd_eid_interworking(hapd, pos);
72 pos = hostapd_eid_adv_proto(hapd, pos);
73 pos = hostapd_eid_roaming_consortium(hapd, pos);
75 if (wpabuf_resize(&beacon, pos - buf) != 0)
77 wpabuf_put_data(beacon, buf, pos - buf);
79 if (wpabuf_resize(&proberesp, pos - buf) != 0)
81 wpabuf_put_data(proberesp, buf, pos - buf);
85 if (hapd->iface->fst_ies) {
86 size_t add = wpabuf_len(hapd->iface->fst_ies);
88 if (wpabuf_resize(&beacon, add) < 0)
90 wpabuf_put_buf(beacon, hapd->iface->fst_ies);
91 if (wpabuf_resize(&proberesp, add) < 0)
93 wpabuf_put_buf(proberesp, hapd->iface->fst_ies);
94 if (wpabuf_resize(&assocresp, add) < 0)
96 wpabuf_put_buf(assocresp, hapd->iface->fst_ies);
98 #endif /* CONFIG_FST */
100 if (hapd->wps_beacon_ie) {
101 if (wpabuf_resize(&beacon, wpabuf_len(hapd->wps_beacon_ie)) <
104 wpabuf_put_buf(beacon, hapd->wps_beacon_ie);
107 if (hapd->wps_probe_resp_ie) {
108 if (wpabuf_resize(&proberesp,
109 wpabuf_len(hapd->wps_probe_resp_ie)) < 0)
111 wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie);
115 if (hapd->p2p_beacon_ie) {
116 if (wpabuf_resize(&beacon, wpabuf_len(hapd->p2p_beacon_ie)) <
119 wpabuf_put_buf(beacon, hapd->p2p_beacon_ie);
122 if (hapd->p2p_probe_resp_ie) {
123 if (wpabuf_resize(&proberesp,
124 wpabuf_len(hapd->p2p_probe_resp_ie)) < 0)
126 wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie);
128 #endif /* CONFIG_P2P */
130 #ifdef CONFIG_P2P_MANAGER
131 if (hapd->conf->p2p & P2P_MANAGE) {
132 if (wpabuf_resize(&beacon, 100) == 0) {
134 start = wpabuf_put(beacon, 0);
135 p = hostapd_eid_p2p_manage(hapd, start);
136 wpabuf_put(beacon, p - start);
139 if (wpabuf_resize(&proberesp, 100) == 0) {
141 start = wpabuf_put(proberesp, 0);
142 p = hostapd_eid_p2p_manage(hapd, start);
143 wpabuf_put(proberesp, p - start);
146 #endif /* CONFIG_P2P_MANAGER */
149 if (hapd->conf->wps_state) {
150 struct wpabuf *a = wps_build_assoc_resp_ie();
151 if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0)
152 wpabuf_put_buf(assocresp, a);
155 #endif /* CONFIG_WPS */
157 #ifdef CONFIG_P2P_MANAGER
158 if (hapd->conf->p2p & P2P_MANAGE) {
159 if (wpabuf_resize(&assocresp, 100) == 0) {
161 start = wpabuf_put(assocresp, 0);
162 p = hostapd_eid_p2p_manage(hapd, start);
163 wpabuf_put(assocresp, p - start);
166 #endif /* CONFIG_P2P_MANAGER */
168 #ifdef CONFIG_WIFI_DISPLAY
169 if (hapd->p2p_group) {
171 a = p2p_group_assoc_resp_ie(hapd->p2p_group, P2P_SC_SUCCESS);
172 if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0)
173 wpabuf_put_buf(assocresp, a);
176 #endif /* CONFIG_WIFI_DISPLAY */
180 pos = hostapd_eid_hs20_indication(hapd, pos);
182 if (wpabuf_resize(&beacon, pos - buf) != 0)
184 wpabuf_put_data(beacon, buf, pos - buf);
186 if (wpabuf_resize(&proberesp, pos - buf) != 0)
188 wpabuf_put_data(proberesp, buf, pos - buf);
191 pos = hostapd_eid_osen(hapd, buf);
193 if (wpabuf_resize(&beacon, pos - buf) != 0)
195 wpabuf_put_data(beacon, buf, pos - buf);
197 if (wpabuf_resize(&proberesp, pos - buf) != 0)
199 wpabuf_put_data(proberesp, buf, pos - buf);
201 #endif /* CONFIG_HS20 */
203 if (hapd->conf->vendor_elements) {
204 size_t add = wpabuf_len(hapd->conf->vendor_elements);
205 if (wpabuf_resize(&beacon, add) == 0)
206 wpabuf_put_buf(beacon, hapd->conf->vendor_elements);
207 if (wpabuf_resize(&proberesp, add) == 0)
208 wpabuf_put_buf(proberesp, hapd->conf->vendor_elements);
211 *beacon_ret = beacon;
212 *proberesp_ret = proberesp;
213 *assocresp_ret = assocresp;
219 wpabuf_free(proberesp);
220 wpabuf_free(assocresp);
225 void hostapd_free_ap_extra_ies(struct hostapd_data *hapd,
226 struct wpabuf *beacon,
227 struct wpabuf *proberesp,
228 struct wpabuf *assocresp)
231 wpabuf_free(proberesp);
232 wpabuf_free(assocresp);
236 int hostapd_reset_ap_wps_ie(struct hostapd_data *hapd)
238 if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
241 return hapd->driver->set_ap_wps_ie(hapd->drv_priv, NULL, NULL, NULL);
245 int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
247 struct wpabuf *beacon, *proberesp, *assocresp;
250 if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
253 if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
257 ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
260 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
266 int hostapd_set_authorized(struct hostapd_data *hapd,
267 struct sta_info *sta, int authorized)
270 return hostapd_sta_set_flags(hapd, sta->addr,
271 hostapd_sta_flags_to_drv(
273 WPA_STA_AUTHORIZED, ~0);
276 return hostapd_sta_set_flags(hapd, sta->addr,
277 hostapd_sta_flags_to_drv(sta->flags),
278 0, ~WPA_STA_AUTHORIZED);
282 int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta)
284 int set_flags, total_flags, flags_and, flags_or;
285 total_flags = hostapd_sta_flags_to_drv(sta->flags);
286 set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
287 if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
288 sta->auth_alg == WLAN_AUTH_FT) &&
289 sta->flags & WLAN_STA_AUTHORIZED)
290 set_flags |= WPA_STA_AUTHORIZED;
291 flags_or = total_flags & set_flags;
292 flags_and = total_flags | ~set_flags;
293 return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
294 flags_or, flags_and);
298 int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
301 struct wpa_bss_params params;
302 os_memset(¶ms, 0, sizeof(params));
303 params.ifname = ifname;
304 params.enabled = enabled;
306 params.wpa = hapd->conf->wpa;
307 params.ieee802_1x = hapd->conf->ieee802_1x;
308 params.wpa_group = hapd->conf->wpa_group;
309 if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) ==
310 (WPA_PROTO_WPA | WPA_PROTO_RSN))
311 params.wpa_pairwise = hapd->conf->wpa_pairwise |
312 hapd->conf->rsn_pairwise;
313 else if (hapd->conf->wpa & WPA_PROTO_RSN)
314 params.wpa_pairwise = hapd->conf->rsn_pairwise;
315 else if (hapd->conf->wpa & WPA_PROTO_WPA)
316 params.wpa_pairwise = hapd->conf->wpa_pairwise;
317 params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
318 params.rsn_preauth = hapd->conf->rsn_preauth;
319 #ifdef CONFIG_IEEE80211W
320 params.ieee80211w = hapd->conf->ieee80211w;
321 #endif /* CONFIG_IEEE80211W */
323 return hostapd_set_ieee8021x(hapd, ¶ms);
327 int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
329 char force_ifname[IFNAMSIZ];
330 u8 if_addr[ETH_ALEN];
331 return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr,
332 NULL, NULL, force_ifname, if_addr, NULL, 0);
336 int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname)
338 return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
342 int hostapd_set_wds_sta(struct hostapd_data *hapd, char *ifname_wds,
343 const u8 *addr, int aid, int val)
345 const char *bridge = NULL;
347 if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
349 if (hapd->conf->wds_bridge[0])
350 bridge = hapd->conf->wds_bridge;
351 else if (hapd->conf->bridge[0])
352 bridge = hapd->conf->bridge;
353 return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val,
358 int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
361 if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL)
363 return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg);
367 int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
368 u16 seq, u16 status, const u8 *ie, size_t len)
370 if (hapd->driver == NULL || hapd->driver->sta_auth == NULL)
372 return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr,
373 seq, status, ie, len);
377 int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr,
378 int reassoc, u16 status, const u8 *ie, size_t len)
380 if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL)
382 return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr,
383 reassoc, status, ie, len);
387 int hostapd_sta_add(struct hostapd_data *hapd,
388 const u8 *addr, u16 aid, u16 capability,
389 const u8 *supp_rates, size_t supp_rates_len,
391 const struct ieee80211_ht_capabilities *ht_capab,
392 const struct ieee80211_vht_capabilities *vht_capab,
393 u32 flags, u8 qosinfo, u8 vht_opmode)
395 struct hostapd_sta_add_params params;
397 if (hapd->driver == NULL)
399 if (hapd->driver->sta_add == NULL)
402 os_memset(¶ms, 0, sizeof(params));
405 params.capability = capability;
406 params.supp_rates = supp_rates;
407 params.supp_rates_len = supp_rates_len;
408 params.listen_interval = listen_interval;
409 params.ht_capabilities = ht_capab;
410 params.vht_capabilities = vht_capab;
411 params.vht_opmode_enabled = !!(flags & WLAN_STA_VHT_OPMODE_ENABLED);
412 params.vht_opmode = vht_opmode;
413 params.flags = hostapd_sta_flags_to_drv(flags);
414 params.qosinfo = qosinfo;
415 return hapd->driver->sta_add(hapd->drv_priv, ¶ms);
419 int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr,
420 u8 *tspec_ie, size_t tspec_ielen)
422 if (hapd->driver == NULL || hapd->driver->add_tspec == NULL)
424 return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie,
429 int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
431 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
433 return hapd->driver->set_privacy(hapd->drv_priv, enabled);
437 int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
440 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
442 return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
446 int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
448 if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
450 return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
454 int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
456 if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
458 return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
462 int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
463 const char *ifname, const u8 *addr, void *bss_ctx,
464 void **drv_priv, char *force_ifname, u8 *if_addr,
465 const char *bridge, int use_existing)
467 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
469 return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
470 bss_ctx, drv_priv, force_ifname, if_addr,
471 bridge, use_existing);
475 int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
478 if (hapd->driver == NULL || hapd->drv_priv == NULL ||
479 hapd->driver->if_remove == NULL)
481 return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
485 int hostapd_set_ieee8021x(struct hostapd_data *hapd,
486 struct wpa_bss_params *params)
488 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
490 return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
494 int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
495 const u8 *addr, int idx, u8 *seq)
497 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
499 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
504 int hostapd_flush(struct hostapd_data *hapd)
506 if (hapd->driver == NULL || hapd->driver->flush == NULL)
508 return hapd->driver->flush(hapd->drv_priv);
512 int hostapd_set_freq(struct hostapd_data *hapd, enum hostapd_hw_mode mode,
513 int freq, int channel, int ht_enabled, int vht_enabled,
514 int sec_channel_offset, int vht_oper_chwidth,
515 int center_segment0, int center_segment1)
517 struct hostapd_freq_params data;
519 if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled,
520 vht_enabled, sec_channel_offset,
522 center_segment0, center_segment1,
523 hapd->iface->current_mode ?
524 hapd->iface->current_mode->vht_capab : 0))
527 if (hapd->driver == NULL)
529 if (hapd->driver->set_freq == NULL)
531 return hapd->driver->set_freq(hapd->drv_priv, &data);
534 int hostapd_set_rts(struct hostapd_data *hapd, int rts)
536 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
538 return hapd->driver->set_rts(hapd->drv_priv, rts);
542 int hostapd_set_frag(struct hostapd_data *hapd, int frag)
544 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
546 return hapd->driver->set_frag(hapd->drv_priv, frag);
550 int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
551 int total_flags, int flags_or, int flags_and)
553 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
555 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
556 flags_or, flags_and);
560 int hostapd_set_country(struct hostapd_data *hapd, const char *country)
562 if (hapd->driver == NULL ||
563 hapd->driver->set_country == NULL)
565 return hapd->driver->set_country(hapd->drv_priv, country);
569 int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
570 int cw_min, int cw_max, int burst_time)
572 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
574 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
575 cw_min, cw_max, burst_time);
579 struct hostapd_hw_modes *
580 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
583 if (hapd->driver == NULL ||
584 hapd->driver->get_hw_feature_data == NULL)
586 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
591 int hostapd_driver_commit(struct hostapd_data *hapd)
593 if (hapd->driver == NULL || hapd->driver->commit == NULL)
595 return hapd->driver->commit(hapd->drv_priv);
599 int hostapd_drv_none(struct hostapd_data *hapd)
601 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
605 int hostapd_driver_scan(struct hostapd_data *hapd,
606 struct wpa_driver_scan_params *params)
608 if (hapd->driver && hapd->driver->scan2)
609 return hapd->driver->scan2(hapd->drv_priv, params);
614 struct wpa_scan_results * hostapd_driver_get_scan_results(
615 struct hostapd_data *hapd)
617 if (hapd->driver && hapd->driver->get_scan_results2)
618 return hapd->driver->get_scan_results2(hapd->drv_priv);
623 int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
626 if (hapd->driver && hapd->driver->set_noa)
627 return hapd->driver->set_noa(hapd->drv_priv, count, start,
633 int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
634 enum wpa_alg alg, const u8 *addr,
635 int key_idx, int set_tx,
636 const u8 *seq, size_t seq_len,
637 const u8 *key, size_t key_len)
639 if (hapd->driver == NULL || hapd->driver->set_key == NULL)
641 return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
642 key_idx, set_tx, seq, seq_len, key,
647 int hostapd_drv_send_mlme(struct hostapd_data *hapd,
648 const void *msg, size_t len, int noack)
650 if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
652 return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0);
656 int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
657 const u8 *addr, int reason)
659 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
661 return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
666 int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
667 const u8 *addr, int reason)
669 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
671 return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
676 int hostapd_drv_wnm_oper(struct hostapd_data *hapd, enum wnm_oper oper,
677 const u8 *peer, u8 *buf, u16 *buf_len)
679 if (hapd->driver == NULL || hapd->driver->wnm_oper == NULL)
681 return hapd->driver->wnm_oper(hapd->drv_priv, oper, peer, buf,
686 int hostapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq,
687 unsigned int wait, const u8 *dst, const u8 *data,
690 if (hapd->driver == NULL || hapd->driver->send_action == NULL)
692 return hapd->driver->send_action(hapd->drv_priv, freq, wait, dst,
693 hapd->own_addr, hapd->own_addr, data,
698 int hostapd_start_dfs_cac(struct hostapd_iface *iface,
699 enum hostapd_hw_mode mode, int freq,
700 int channel, int ht_enabled, int vht_enabled,
701 int sec_channel_offset, int vht_oper_chwidth,
702 int center_segment0, int center_segment1)
704 struct hostapd_data *hapd = iface->bss[0];
705 struct hostapd_freq_params data;
708 if (!hapd->driver || !hapd->driver->start_dfs_cac)
711 if (!iface->conf->ieee80211h) {
712 wpa_printf(MSG_ERROR, "Can't start DFS CAC, DFS functionality "
717 if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled,
718 vht_enabled, sec_channel_offset,
719 vht_oper_chwidth, center_segment0,
721 iface->current_mode->vht_capab)) {
722 wpa_printf(MSG_ERROR, "Can't set freq params");
726 res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data);
728 iface->cac_started = 1;
729 os_get_reltime(&iface->dfs_cac_start);
736 int hostapd_drv_set_qos_map(struct hostapd_data *hapd,
737 const u8 *qos_map_set, u8 qos_map_set_len)
739 if (hapd->driver == NULL || hapd->driver->set_qos_map == NULL)
741 return hapd->driver->set_qos_map(hapd->drv_priv, qos_map_set,
746 static void hostapd_get_hw_mode_any_channels(struct hostapd_data *hapd,
747 struct hostapd_hw_modes *mode,
753 for (i = 0; i < mode->num_channels; i++) {
754 struct hostapd_channel_data *chan = &mode->channels[i];
756 if ((acs_ch_list_all ||
757 freq_range_list_includes(&hapd->iface->conf->acs_ch_list,
759 !(chan->flag & HOSTAPD_CHAN_DISABLED))
760 int_array_add_unique(freq_list, chan->freq);
765 int hostapd_drv_do_acs(struct hostapd_data *hapd)
767 struct drv_acs_params params;
768 int ret, i, acs_ch_list_all = 0;
770 unsigned int num_channels = 0;
771 struct hostapd_hw_modes *mode;
772 int *freq_list = NULL;
774 if (hapd->driver == NULL || hapd->driver->do_acs == NULL)
777 os_memset(¶ms, 0, sizeof(params));
778 params.hw_mode = hapd->iface->conf->hw_mode;
781 * If no chanlist config parameter is provided, include all enabled
782 * channels of the selected hw_mode.
784 if (!hapd->iface->conf->acs_ch_list.num)
787 mode = hapd->iface->current_mode;
789 channels = os_malloc(mode->num_channels);
790 if (channels == NULL)
793 for (i = 0; i < mode->num_channels; i++) {
794 struct hostapd_channel_data *chan = &mode->channels[i];
795 if (!acs_ch_list_all &&
796 !freq_range_list_includes(
797 &hapd->iface->conf->acs_ch_list,
800 if (!(chan->flag & HOSTAPD_CHAN_DISABLED)) {
801 channels[num_channels++] = chan->chan;
802 int_array_add_unique(&freq_list, chan->freq);
806 for (i = 0; i < hapd->iface->num_hw_features; i++) {
807 mode = &hapd->iface->hw_features[i];
808 hostapd_get_hw_mode_any_channels(hapd, mode,
814 params.ch_list = channels;
815 params.ch_list_len = num_channels;
816 params.freq_list = freq_list;
818 params.ht_enabled = !!(hapd->iface->conf->ieee80211n);
819 params.ht40_enabled = !!(hapd->iface->conf->ht_capab &
820 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET);
821 params.vht_enabled = !!(hapd->iface->conf->ieee80211ac);
822 params.ch_width = 20;
823 if (hapd->iface->conf->ieee80211n && params.ht40_enabled)
824 params.ch_width = 40;
826 /* Note: VHT20 is defined by combination of ht_capab & vht_oper_chwidth
828 if (hapd->iface->conf->ieee80211ac && params.ht40_enabled) {
829 if (hapd->iface->conf->vht_oper_chwidth == VHT_CHANWIDTH_80MHZ)
830 params.ch_width = 80;
831 else if (hapd->iface->conf->vht_oper_chwidth ==
832 VHT_CHANWIDTH_160MHZ ||
833 hapd->iface->conf->vht_oper_chwidth ==
834 VHT_CHANWIDTH_80P80MHZ)
835 params.ch_width = 160;
838 ret = hapd->driver->do_acs(hapd->drv_priv, ¶ms);