2009-12-24 15:15:22 +01:00
|
|
|
/*
|
|
|
|
* hostapd - Driver operations
|
2010-03-13 20:43:00 +01:00
|
|
|
* Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
|
2009-12-24 15:15:22 +01:00
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-12-24 15:15:22 +01:00
|
|
|
*/
|
|
|
|
|
2009-12-25 23:12:25 +01:00
|
|
|
#include "utils/includes.h"
|
2009-12-24 15:15:22 +01:00
|
|
|
|
2009-12-25 23:12:25 +01:00
|
|
|
#include "utils/common.h"
|
2010-03-13 20:43:00 +01:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2015-02-19 07:15:47 +01:00
|
|
|
#include "common/hw_features_common.h"
|
2010-09-22 19:46:44 +02:00
|
|
|
#include "wps/wps.h"
|
2012-03-02 16:26:01 +01:00
|
|
|
#include "p2p/p2p.h"
|
2009-12-25 23:12:25 +01:00
|
|
|
#include "hostapd.h"
|
|
|
|
#include "ieee802_11.h"
|
|
|
|
#include "sta_info.h"
|
|
|
|
#include "ap_config.h"
|
2010-10-08 17:16:07 +02:00
|
|
|
#include "p2p_hostapd.h"
|
2011-09-08 19:52:23 +02:00
|
|
|
#include "hs20.h"
|
2009-12-25 13:20:35 +01:00
|
|
|
#include "ap_drv_ops.h"
|
2009-12-24 15:15:22 +01:00
|
|
|
|
|
|
|
|
2011-04-02 21:03:05 +02:00
|
|
|
u32 hostapd_sta_flags_to_drv(u32 flags)
|
2009-12-24 22:11:16 +01:00
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
if (flags & WLAN_STA_AUTHORIZED)
|
|
|
|
res |= WPA_STA_AUTHORIZED;
|
|
|
|
if (flags & WLAN_STA_WMM)
|
|
|
|
res |= WPA_STA_WMM;
|
|
|
|
if (flags & WLAN_STA_SHORT_PREAMBLE)
|
|
|
|
res |= WPA_STA_SHORT_PREAMBLE;
|
|
|
|
if (flags & WLAN_STA_MFP)
|
|
|
|
res |= WPA_STA_MFP;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 20:14:25 +02:00
|
|
|
int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
|
2011-10-17 19:55:06 +02:00
|
|
|
struct wpabuf **beacon_ret,
|
|
|
|
struct wpabuf **proberesp_ret,
|
|
|
|
struct wpabuf **assocresp_ret)
|
2009-12-24 15:15:22 +01:00
|
|
|
{
|
2011-10-17 19:55:06 +02:00
|
|
|
struct wpabuf *beacon = NULL, *proberesp = NULL, *assocresp = NULL;
|
2011-10-17 22:55:50 +02:00
|
|
|
u8 buf[200], *pos;
|
2011-10-17 19:55:06 +02:00
|
|
|
|
|
|
|
*beacon_ret = *proberesp_ret = *assocresp_ret = NULL;
|
|
|
|
|
2011-10-17 23:24:16 +02:00
|
|
|
pos = buf;
|
|
|
|
pos = hostapd_eid_time_adv(hapd, pos);
|
|
|
|
if (pos != buf) {
|
|
|
|
if (wpabuf_resize(&beacon, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(beacon, buf, pos - buf);
|
|
|
|
}
|
|
|
|
pos = hostapd_eid_time_zone(hapd, pos);
|
|
|
|
if (pos != buf) {
|
|
|
|
if (wpabuf_resize(&proberesp, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(proberesp, buf, pos - buf);
|
|
|
|
}
|
|
|
|
|
2011-10-17 20:30:44 +02:00
|
|
|
pos = buf;
|
|
|
|
pos = hostapd_eid_ext_capab(hapd, pos);
|
|
|
|
if (pos != buf) {
|
|
|
|
if (wpabuf_resize(&assocresp, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(assocresp, buf, pos - buf);
|
|
|
|
}
|
|
|
|
pos = hostapd_eid_interworking(hapd, pos);
|
2011-10-17 22:19:52 +02:00
|
|
|
pos = hostapd_eid_adv_proto(hapd, pos);
|
2011-10-17 22:55:50 +02:00
|
|
|
pos = hostapd_eid_roaming_consortium(hapd, pos);
|
2011-10-17 20:30:44 +02:00
|
|
|
if (pos != buf) {
|
|
|
|
if (wpabuf_resize(&beacon, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(beacon, buf, pos - buf);
|
|
|
|
|
|
|
|
if (wpabuf_resize(&proberesp, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(proberesp, buf, pos - buf);
|
|
|
|
}
|
|
|
|
|
2015-01-21 14:30:48 +01:00
|
|
|
#ifdef CONFIG_FST
|
|
|
|
if (hapd->iface->fst_ies) {
|
|
|
|
size_t add = wpabuf_len(hapd->iface->fst_ies);
|
|
|
|
|
|
|
|
if (wpabuf_resize(&beacon, add) < 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_buf(beacon, hapd->iface->fst_ies);
|
|
|
|
if (wpabuf_resize(&proberesp, add) < 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_buf(proberesp, hapd->iface->fst_ies);
|
|
|
|
if (wpabuf_resize(&assocresp, add) < 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_buf(assocresp, hapd->iface->fst_ies);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_FST */
|
|
|
|
|
2011-10-17 19:55:06 +02:00
|
|
|
if (hapd->wps_beacon_ie) {
|
|
|
|
if (wpabuf_resize(&beacon, wpabuf_len(hapd->wps_beacon_ie)) <
|
|
|
|
0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_buf(beacon, hapd->wps_beacon_ie);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hapd->wps_probe_resp_ie) {
|
|
|
|
if (wpabuf_resize(&proberesp,
|
|
|
|
wpabuf_len(hapd->wps_probe_resp_ie)) < 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie);
|
|
|
|
}
|
2010-04-11 19:16:43 +02:00
|
|
|
|
2010-07-18 23:30:25 +02:00
|
|
|
#ifdef CONFIG_P2P
|
2011-10-17 19:55:06 +02:00
|
|
|
if (hapd->p2p_beacon_ie) {
|
|
|
|
if (wpabuf_resize(&beacon, wpabuf_len(hapd->p2p_beacon_ie)) <
|
|
|
|
0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_buf(beacon, hapd->p2p_beacon_ie);
|
2010-07-18 23:30:25 +02:00
|
|
|
}
|
|
|
|
|
2011-10-17 19:55:06 +02:00
|
|
|
if (hapd->p2p_probe_resp_ie) {
|
2011-11-14 15:10:54 +01:00
|
|
|
if (wpabuf_resize(&proberesp,
|
|
|
|
wpabuf_len(hapd->p2p_probe_resp_ie)) < 0)
|
2011-10-17 19:55:06 +02:00
|
|
|
goto fail;
|
2011-11-14 15:10:54 +01:00
|
|
|
wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie);
|
2010-07-18 23:30:25 +02:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_P2P */
|
|
|
|
|
2010-10-08 17:16:07 +02:00
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
if (hapd->conf->p2p & P2P_MANAGE) {
|
2011-10-17 19:55:06 +02:00
|
|
|
if (wpabuf_resize(&beacon, 100) == 0) {
|
2010-10-08 17:16:07 +02:00
|
|
|
u8 *start, *p;
|
2011-10-17 19:55:06 +02:00
|
|
|
start = wpabuf_put(beacon, 0);
|
2010-10-08 17:16:07 +02:00
|
|
|
p = hostapd_eid_p2p_manage(hapd, start);
|
2011-10-17 19:55:06 +02:00
|
|
|
wpabuf_put(beacon, p - start);
|
2010-10-08 17:16:07 +02:00
|
|
|
}
|
|
|
|
|
2011-10-17 19:55:06 +02:00
|
|
|
if (wpabuf_resize(&proberesp, 100) == 0) {
|
2010-10-08 17:16:07 +02:00
|
|
|
u8 *start, *p;
|
2011-10-17 19:55:06 +02:00
|
|
|
start = wpabuf_put(proberesp, 0);
|
2010-10-08 17:16:07 +02:00
|
|
|
p = hostapd_eid_p2p_manage(hapd, start);
|
2011-10-17 19:55:06 +02:00
|
|
|
wpabuf_put(proberesp, p - start);
|
2010-10-08 17:16:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
2014-03-25 16:40:50 +01:00
|
|
|
#ifdef CONFIG_WPS
|
2011-10-17 19:55:06 +02:00
|
|
|
if (hapd->conf->wps_state) {
|
|
|
|
struct wpabuf *a = wps_build_assoc_resp_ie();
|
|
|
|
if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0)
|
|
|
|
wpabuf_put_buf(assocresp, a);
|
|
|
|
wpabuf_free(a);
|
|
|
|
}
|
2014-03-25 16:40:50 +01:00
|
|
|
#endif /* CONFIG_WPS */
|
2010-09-22 19:46:44 +02:00
|
|
|
|
2010-10-08 17:16:07 +02:00
|
|
|
#ifdef CONFIG_P2P_MANAGER
|
|
|
|
if (hapd->conf->p2p & P2P_MANAGE) {
|
2011-10-17 19:55:06 +02:00
|
|
|
if (wpabuf_resize(&assocresp, 100) == 0) {
|
2010-10-08 17:16:07 +02:00
|
|
|
u8 *start, *p;
|
2011-10-17 19:55:06 +02:00
|
|
|
start = wpabuf_put(assocresp, 0);
|
2010-10-08 17:16:07 +02:00
|
|
|
p = hostapd_eid_p2p_manage(hapd, start);
|
2011-10-17 19:55:06 +02:00
|
|
|
wpabuf_put(assocresp, p - start);
|
2010-10-08 17:16:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_P2P_MANAGER */
|
|
|
|
|
2012-03-02 16:26:01 +01:00
|
|
|
#ifdef CONFIG_WIFI_DISPLAY
|
|
|
|
if (hapd->p2p_group) {
|
|
|
|
struct wpabuf *a;
|
|
|
|
a = p2p_group_assoc_resp_ie(hapd->p2p_group, P2P_SC_SUCCESS);
|
|
|
|
if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0)
|
|
|
|
wpabuf_put_buf(assocresp, a);
|
|
|
|
wpabuf_free(a);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_WIFI_DISPLAY */
|
|
|
|
|
2011-09-08 19:52:23 +02:00
|
|
|
#ifdef CONFIG_HS20
|
|
|
|
pos = buf;
|
|
|
|
pos = hostapd_eid_hs20_indication(hapd, pos);
|
|
|
|
if (pos != buf) {
|
|
|
|
if (wpabuf_resize(&beacon, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(beacon, buf, pos - buf);
|
|
|
|
|
|
|
|
if (wpabuf_resize(&proberesp, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(proberesp, buf, pos - buf);
|
|
|
|
}
|
2013-07-23 20:25:21 +02:00
|
|
|
|
|
|
|
pos = hostapd_eid_osen(hapd, buf);
|
|
|
|
if (pos != buf) {
|
|
|
|
if (wpabuf_resize(&beacon, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(beacon, buf, pos - buf);
|
|
|
|
|
|
|
|
if (wpabuf_resize(&proberesp, pos - buf) != 0)
|
|
|
|
goto fail;
|
|
|
|
wpabuf_put_data(proberesp, buf, pos - buf);
|
|
|
|
}
|
2011-09-08 19:52:23 +02:00
|
|
|
#endif /* CONFIG_HS20 */
|
|
|
|
|
2013-03-21 14:41:27 +01:00
|
|
|
if (hapd->conf->vendor_elements) {
|
|
|
|
size_t add = wpabuf_len(hapd->conf->vendor_elements);
|
|
|
|
if (wpabuf_resize(&beacon, add) == 0)
|
|
|
|
wpabuf_put_buf(beacon, hapd->conf->vendor_elements);
|
|
|
|
if (wpabuf_resize(&proberesp, add) == 0)
|
|
|
|
wpabuf_put_buf(proberesp, hapd->conf->vendor_elements);
|
|
|
|
}
|
|
|
|
|
2011-10-17 19:55:06 +02:00
|
|
|
*beacon_ret = beacon;
|
|
|
|
*proberesp_ret = proberesp;
|
|
|
|
*assocresp_ret = assocresp;
|
|
|
|
|
2011-08-26 20:14:25 +02:00
|
|
|
return 0;
|
2011-10-17 19:55:06 +02:00
|
|
|
|
|
|
|
fail:
|
|
|
|
wpabuf_free(beacon);
|
|
|
|
wpabuf_free(proberesp);
|
|
|
|
wpabuf_free(assocresp);
|
|
|
|
return -1;
|
2011-08-26 20:14:25 +02:00
|
|
|
}
|
|
|
|
|
2010-04-11 19:16:43 +02:00
|
|
|
|
2011-10-17 19:55:06 +02:00
|
|
|
void hostapd_free_ap_extra_ies(struct hostapd_data *hapd,
|
|
|
|
struct wpabuf *beacon,
|
2011-08-26 20:14:25 +02:00
|
|
|
struct wpabuf *proberesp,
|
|
|
|
struct wpabuf *assocresp)
|
|
|
|
{
|
2011-10-17 19:55:06 +02:00
|
|
|
wpabuf_free(beacon);
|
|
|
|
wpabuf_free(proberesp);
|
2010-09-22 19:46:44 +02:00
|
|
|
wpabuf_free(assocresp);
|
2011-08-26 20:14:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-24 14:05:43 +01:00
|
|
|
int hostapd_reset_ap_wps_ie(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return hapd->driver->set_ap_wps_ie(hapd->drv_priv, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 20:14:25 +02:00
|
|
|
int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
struct wpabuf *beacon, *proberesp, *assocresp;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
|
|
|
|
0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
|
|
|
|
assocresp);
|
|
|
|
|
|
|
|
hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
|
2010-07-18 23:30:25 +02:00
|
|
|
|
2010-04-11 19:16:43 +02:00
|
|
|
return ret;
|
2009-12-24 15:15:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 15:50:06 +01:00
|
|
|
int hostapd_set_authorized(struct hostapd_data *hapd,
|
|
|
|
struct sta_info *sta, int authorized)
|
2009-12-24 19:41:30 +01:00
|
|
|
{
|
|
|
|
if (authorized) {
|
|
|
|
return hostapd_sta_set_flags(hapd, sta->addr,
|
|
|
|
hostapd_sta_flags_to_drv(
|
|
|
|
sta->flags),
|
|
|
|
WPA_STA_AUTHORIZED, ~0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hostapd_sta_set_flags(hapd, sta->addr,
|
|
|
|
hostapd_sta_flags_to_drv(sta->flags),
|
|
|
|
0, ~WPA_STA_AUTHORIZED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 15:50:06 +01:00
|
|
|
int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta)
|
2009-12-24 22:11:16 +01:00
|
|
|
{
|
|
|
|
int set_flags, total_flags, flags_and, flags_or;
|
|
|
|
total_flags = hostapd_sta_flags_to_drv(sta->flags);
|
|
|
|
set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
|
2010-03-13 20:43:00 +01:00
|
|
|
if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
|
|
|
|
sta->auth_alg == WLAN_AUTH_FT) &&
|
2009-12-24 22:11:16 +01:00
|
|
|
sta->flags & WLAN_STA_AUTHORIZED)
|
|
|
|
set_flags |= WPA_STA_AUTHORIZED;
|
|
|
|
flags_or = total_flags & set_flags;
|
|
|
|
flags_and = total_flags | ~set_flags;
|
|
|
|
return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
|
|
|
|
flags_or, flags_and);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 15:50:06 +01:00
|
|
|
int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
|
|
|
|
int enabled)
|
2009-12-24 22:17:11 +01:00
|
|
|
{
|
|
|
|
struct wpa_bss_params params;
|
|
|
|
os_memset(¶ms, 0, sizeof(params));
|
|
|
|
params.ifname = ifname;
|
|
|
|
params.enabled = enabled;
|
|
|
|
if (enabled) {
|
|
|
|
params.wpa = hapd->conf->wpa;
|
|
|
|
params.ieee802_1x = hapd->conf->ieee802_1x;
|
|
|
|
params.wpa_group = hapd->conf->wpa_group;
|
2015-03-25 10:41:26 +01:00
|
|
|
if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) ==
|
|
|
|
(WPA_PROTO_WPA | WPA_PROTO_RSN))
|
|
|
|
params.wpa_pairwise = hapd->conf->wpa_pairwise |
|
|
|
|
hapd->conf->rsn_pairwise;
|
|
|
|
else if (hapd->conf->wpa & WPA_PROTO_RSN)
|
|
|
|
params.wpa_pairwise = hapd->conf->rsn_pairwise;
|
|
|
|
else if (hapd->conf->wpa & WPA_PROTO_WPA)
|
|
|
|
params.wpa_pairwise = hapd->conf->wpa_pairwise;
|
2009-12-24 22:17:11 +01:00
|
|
|
params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
|
|
|
|
params.rsn_preauth = hapd->conf->rsn_preauth;
|
2011-04-08 11:06:27 +02:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
params.ieee80211w = hapd->conf->ieee80211w;
|
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2009-12-24 22:17:11 +01:00
|
|
|
}
|
|
|
|
return hostapd_set_ieee8021x(hapd, ¶ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 15:50:06 +01:00
|
|
|
int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
|
2009-12-24 23:17:07 +01:00
|
|
|
{
|
2010-04-11 18:23:09 +02:00
|
|
|
char force_ifname[IFNAMSIZ];
|
|
|
|
u8 if_addr[ETH_ALEN];
|
2011-02-24 20:25:40 +01:00
|
|
|
return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr,
|
2013-10-31 18:41:42 +01:00
|
|
|
NULL, NULL, force_ifname, if_addr, NULL, 0);
|
2009-12-24 23:17:07 +01:00
|
|
|
}
|
|
|
|
|
2010-11-24 15:50:06 +01:00
|
|
|
|
|
|
|
int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname)
|
2009-12-24 23:17:07 +01:00
|
|
|
{
|
|
|
|
return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-20 16:41:22 +02:00
|
|
|
int hostapd_set_wds_sta(struct hostapd_data *hapd, char *ifname_wds,
|
|
|
|
const u8 *addr, int aid, int val)
|
2009-12-24 23:30:16 +01:00
|
|
|
{
|
2010-11-09 15:12:42 +01:00
|
|
|
const char *bridge = NULL;
|
|
|
|
|
2009-12-24 23:30:16 +01:00
|
|
|
if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
|
2013-07-20 16:41:22 +02:00
|
|
|
return -1;
|
2010-11-09 15:12:42 +01:00
|
|
|
if (hapd->conf->wds_bridge[0])
|
|
|
|
bridge = hapd->conf->wds_bridge;
|
|
|
|
else if (hapd->conf->bridge[0])
|
|
|
|
bridge = hapd->conf->bridge;
|
2010-11-24 15:50:06 +01:00
|
|
|
return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val,
|
2013-07-20 16:41:22 +02:00
|
|
|
bridge, ifname_wds);
|
2009-12-24 23:30:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 23:05:29 +02:00
|
|
|
int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
u16 auth_alg)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
u16 seq, u16 status, const u8 *ie, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_auth == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
seq, status, ie, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
int reassoc, u16 status, const u8 *ie, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
reassoc, status, ie, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 15:50:06 +01:00
|
|
|
int hostapd_sta_add(struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, u16 aid, u16 capability,
|
|
|
|
const u8 *supp_rates, size_t supp_rates_len,
|
|
|
|
u16 listen_interval,
|
2011-07-12 19:26:52 +02:00
|
|
|
const struct ieee80211_ht_capabilities *ht_capab,
|
2012-12-28 16:30:30 +01:00
|
|
|
const struct ieee80211_vht_capabilities *vht_capab,
|
2014-02-10 13:43:05 +01:00
|
|
|
u32 flags, u8 qosinfo, u8 vht_opmode)
|
2009-12-24 23:35:10 +01:00
|
|
|
{
|
|
|
|
struct hostapd_sta_add_params params;
|
|
|
|
|
|
|
|
if (hapd->driver == NULL)
|
|
|
|
return 0;
|
|
|
|
if (hapd->driver->sta_add == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
os_memset(¶ms, 0, sizeof(params));
|
|
|
|
params.addr = addr;
|
|
|
|
params.aid = aid;
|
|
|
|
params.capability = capability;
|
|
|
|
params.supp_rates = supp_rates;
|
|
|
|
params.supp_rates_len = supp_rates_len;
|
|
|
|
params.listen_interval = listen_interval;
|
|
|
|
params.ht_capabilities = ht_capab;
|
2012-12-28 16:30:30 +01:00
|
|
|
params.vht_capabilities = vht_capab;
|
2014-02-10 13:43:05 +01:00
|
|
|
params.vht_opmode_enabled = !!(flags & WLAN_STA_VHT_OPMODE_ENABLED);
|
|
|
|
params.vht_opmode = vht_opmode;
|
2011-07-12 19:26:52 +02:00
|
|
|
params.flags = hostapd_sta_flags_to_drv(flags);
|
2011-12-17 11:38:06 +01:00
|
|
|
params.qosinfo = qosinfo;
|
2010-03-07 10:42:41 +01:00
|
|
|
return hapd->driver->sta_add(hapd->drv_priv, ¶ms);
|
2009-12-24 23:35:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-29 23:05:29 +02:00
|
|
|
int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr,
|
|
|
|
u8 *tspec_ie, size_t tspec_ielen)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->add_tspec == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie,
|
|
|
|
tspec_ielen);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-25 23:12:25 +01:00
|
|
|
int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
|
|
|
|
return 0;
|
2010-03-07 10:29:17 +01:00
|
|
|
return hapd->driver->set_privacy(hapd->drv_priv, enabled);
|
2009-12-25 23:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
|
|
|
|
size_t elem_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
|
|
|
|
return 0;
|
2010-03-07 10:33:06 +01:00
|
|
|
return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
|
2009-12-25 23:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
|
|
|
|
return 0;
|
2010-03-07 10:36:45 +01:00
|
|
|
return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
|
2009-12-25 23:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
|
|
|
|
return 0;
|
2010-03-07 10:36:45 +01:00
|
|
|
return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
|
2009-12-25 23:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
|
2010-03-06 21:22:56 +01:00
|
|
|
const char *ifname, const u8 *addr, void *bss_ctx,
|
2011-03-15 12:02:49 +01:00
|
|
|
void **drv_priv, char *force_ifname, u8 *if_addr,
|
2013-10-31 18:41:42 +01:00
|
|
|
const char *bridge, int use_existing)
|
2009-12-25 23:12:25 +01:00
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->if_add == NULL)
|
|
|
|
return -1;
|
2010-03-07 09:05:05 +01:00
|
|
|
return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
|
2011-03-15 12:02:49 +01:00
|
|
|
bss_ctx, drv_priv, force_ifname, if_addr,
|
2015-11-03 15:30:09 +01:00
|
|
|
bridge, use_existing, 1);
|
2009-12-25 23:12:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
|
|
|
|
const char *ifname)
|
|
|
|
{
|
2013-11-02 18:49:01 +01:00
|
|
|
if (hapd->driver == NULL || hapd->drv_priv == NULL ||
|
|
|
|
hapd->driver->if_remove == NULL)
|
2009-12-25 23:12:25 +01:00
|
|
|
return -1;
|
|
|
|
return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
|
|
|
|
}
|
2009-12-25 23:21:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_ieee8021x(struct hostapd_data *hapd,
|
|
|
|
struct wpa_bss_params *params)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, int idx, u8 *seq)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
|
|
|
|
seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_flush(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->flush == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->flush(hapd->drv_priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-03 15:59:14 +01:00
|
|
|
int hostapd_set_freq(struct hostapd_data *hapd, enum hostapd_hw_mode mode,
|
|
|
|
int freq, int channel, int ht_enabled, int vht_enabled,
|
2013-10-16 11:18:52 +02:00
|
|
|
int sec_channel_offset, int vht_oper_chwidth,
|
|
|
|
int center_segment0, int center_segment1)
|
|
|
|
{
|
|
|
|
struct hostapd_freq_params data;
|
|
|
|
|
|
|
|
if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled,
|
|
|
|
vht_enabled, sec_channel_offset,
|
|
|
|
vht_oper_chwidth,
|
2013-10-27 18:17:23 +01:00
|
|
|
center_segment0, center_segment1,
|
2014-11-17 00:08:04 +01:00
|
|
|
hapd->iface->current_mode ?
|
|
|
|
hapd->iface->current_mode->vht_capab : 0))
|
2013-10-16 11:18:52 +02:00
|
|
|
return -1;
|
|
|
|
|
2012-12-28 16:24:21 +01:00
|
|
|
if (hapd->driver == NULL)
|
|
|
|
return 0;
|
|
|
|
if (hapd->driver->set_freq == NULL)
|
|
|
|
return 0;
|
2009-12-25 23:21:22 +01:00
|
|
|
return hapd->driver->set_freq(hapd->drv_priv, &data);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hostapd_set_rts(struct hostapd_data *hapd, int rts)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_rts(hapd->drv_priv, rts);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_frag(struct hostapd_data *hapd, int frag)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_frag(hapd->drv_priv, frag);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
|
|
|
|
int total_flags, int flags_or, int flags_and)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
|
|
|
|
return 0;
|
2010-03-07 10:45:41 +01:00
|
|
|
return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
|
2009-12-25 23:21:22 +01:00
|
|
|
flags_or, flags_and);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_country(struct hostapd_data *hapd, const char *country)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL ||
|
|
|
|
hapd->driver->set_country == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_country(hapd->drv_priv, country);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
|
|
|
|
int cw_min, int cw_max, int burst_time)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
|
|
|
|
cw_min, cw_max, burst_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct hostapd_hw_modes *
|
|
|
|
hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
|
|
|
|
u16 *flags)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL ||
|
|
|
|
hapd->driver->get_hw_feature_data == NULL)
|
|
|
|
return NULL;
|
|
|
|
return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
|
|
|
|
flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_driver_commit(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->commit == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->commit(hapd->drv_priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_none(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_driver_scan(struct hostapd_data *hapd,
|
|
|
|
struct wpa_driver_scan_params *params)
|
|
|
|
{
|
|
|
|
if (hapd->driver && hapd->driver->scan2)
|
|
|
|
return hapd->driver->scan2(hapd->drv_priv, params);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wpa_scan_results * hostapd_driver_get_scan_results(
|
|
|
|
struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
if (hapd->driver && hapd->driver->get_scan_results2)
|
|
|
|
return hapd->driver->get_scan_results2(hapd->drv_priv);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-07-09 02:14:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
|
|
|
|
int duration)
|
|
|
|
{
|
|
|
|
if (hapd->driver && hapd->driver->set_noa)
|
|
|
|
return hapd->driver->set_noa(hapd->drv_priv, count, start,
|
|
|
|
duration);
|
|
|
|
return -1;
|
|
|
|
}
|
2010-11-24 16:01:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
|
|
|
|
enum wpa_alg alg, const u8 *addr,
|
|
|
|
int key_idx, int set_tx,
|
|
|
|
const u8 *seq, size_t seq_len,
|
|
|
|
const u8 *key, size_t key_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_key == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
|
|
|
|
key_idx, set_tx, seq, seq_len, key,
|
|
|
|
key_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_send_mlme(struct hostapd_data *hapd,
|
2011-11-19 18:02:05 +01:00
|
|
|
const void *msg, size_t len, int noack)
|
2010-11-24 16:01:21 +01:00
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
|
|
|
|
return 0;
|
2015-09-08 11:46:26 +02:00
|
|
|
return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0,
|
|
|
|
NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_send_mlme_csa(struct hostapd_data *hapd,
|
|
|
|
const void *msg, size_t len, int noack,
|
|
|
|
const u16 *csa_offs, size_t csa_offs_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0,
|
|
|
|
csa_offs, csa_offs_len);
|
2010-11-24 16:01:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, int reason)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
|
|
|
|
const u8 *addr, int reason)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
|
|
|
|
reason);
|
|
|
|
}
|
2012-02-26 19:52:31 +01:00
|
|
|
|
|
|
|
|
2012-02-26 16:22:02 +01:00
|
|
|
int hostapd_drv_wnm_oper(struct hostapd_data *hapd, enum wnm_oper oper,
|
|
|
|
const u8 *peer, u8 *buf, u16 *buf_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->wnm_oper == NULL)
|
2013-12-27 17:44:21 +01:00
|
|
|
return -1;
|
2012-02-26 16:22:02 +01:00
|
|
|
return hapd->driver->wnm_oper(hapd->drv_priv, oper, peer, buf,
|
|
|
|
buf_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-26 19:52:31 +01:00
|
|
|
int hostapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq,
|
|
|
|
unsigned int wait, const u8 *dst, const u8 *data,
|
|
|
|
size_t len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->send_action == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->send_action(hapd->drv_priv, freq, wait, dst,
|
|
|
|
hapd->own_addr, hapd->own_addr, data,
|
|
|
|
len, 0);
|
|
|
|
}
|
2013-10-15 19:27:25 +02:00
|
|
|
|
2013-11-03 17:48:03 +01:00
|
|
|
|
2015-01-03 15:59:14 +01:00
|
|
|
int hostapd_start_dfs_cac(struct hostapd_iface *iface,
|
|
|
|
enum hostapd_hw_mode mode, int freq,
|
2013-10-16 11:18:52 +02:00
|
|
|
int channel, int ht_enabled, int vht_enabled,
|
|
|
|
int sec_channel_offset, int vht_oper_chwidth,
|
|
|
|
int center_segment0, int center_segment1)
|
2013-10-15 19:27:25 +02:00
|
|
|
{
|
2013-11-03 17:48:03 +01:00
|
|
|
struct hostapd_data *hapd = iface->bss[0];
|
2013-10-16 11:18:52 +02:00
|
|
|
struct hostapd_freq_params data;
|
2013-10-26 15:36:00 +02:00
|
|
|
int res;
|
2013-10-16 11:18:52 +02:00
|
|
|
|
2013-10-15 19:27:25 +02:00
|
|
|
if (!hapd->driver || !hapd->driver->start_dfs_cac)
|
|
|
|
return 0;
|
|
|
|
|
2013-11-03 17:48:03 +01:00
|
|
|
if (!iface->conf->ieee80211h) {
|
2013-10-15 19:27:25 +02:00
|
|
|
wpa_printf(MSG_ERROR, "Can't start DFS CAC, DFS functionality "
|
|
|
|
"is not enabled");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-16 11:18:52 +02:00
|
|
|
if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled,
|
|
|
|
vht_enabled, sec_channel_offset,
|
|
|
|
vht_oper_chwidth, center_segment0,
|
2013-10-27 18:17:23 +01:00
|
|
|
center_segment1,
|
2014-03-05 09:21:20 +01:00
|
|
|
iface->current_mode->vht_capab)) {
|
|
|
|
wpa_printf(MSG_ERROR, "Can't set freq params");
|
2013-10-16 11:18:52 +02:00
|
|
|
return -1;
|
2014-03-05 09:21:20 +01:00
|
|
|
}
|
2013-10-16 11:18:52 +02:00
|
|
|
|
2013-10-26 15:36:00 +02:00
|
|
|
res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data);
|
2014-03-05 09:23:42 +01:00
|
|
|
if (!res) {
|
2013-11-03 17:48:03 +01:00
|
|
|
iface->cac_started = 1;
|
2014-03-05 09:23:42 +01:00
|
|
|
os_get_reltime(&iface->dfs_cac_start);
|
|
|
|
}
|
2013-10-26 15:36:00 +02:00
|
|
|
|
|
|
|
return res;
|
2013-10-15 19:27:25 +02:00
|
|
|
}
|
2013-07-24 11:28:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
int hostapd_drv_set_qos_map(struct hostapd_data *hapd,
|
|
|
|
const u8 *qos_map_set, u8 qos_map_set_len)
|
|
|
|
{
|
|
|
|
if (hapd->driver == NULL || hapd->driver->set_qos_map == NULL)
|
|
|
|
return 0;
|
|
|
|
return hapd->driver->set_qos_map(hapd->drv_priv, qos_map_set,
|
|
|
|
qos_map_set_len);
|
|
|
|
}
|
2014-11-18 19:11:09 +01:00
|
|
|
|
|
|
|
|
2015-06-20 02:19:27 +02:00
|
|
|
static void hostapd_get_hw_mode_any_channels(struct hostapd_data *hapd,
|
|
|
|
struct hostapd_hw_modes *mode,
|
|
|
|
int acs_ch_list_all,
|
|
|
|
int **freq_list)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < mode->num_channels; i++) {
|
|
|
|
struct hostapd_channel_data *chan = &mode->channels[i];
|
|
|
|
|
|
|
|
if ((acs_ch_list_all ||
|
|
|
|
freq_range_list_includes(&hapd->iface->conf->acs_ch_list,
|
|
|
|
chan->chan)) &&
|
|
|
|
!(chan->flag & HOSTAPD_CHAN_DISABLED))
|
|
|
|
int_array_add_unique(freq_list, chan->freq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-18 19:11:09 +01:00
|
|
|
int hostapd_drv_do_acs(struct hostapd_data *hapd)
|
|
|
|
{
|
|
|
|
struct drv_acs_params params;
|
2015-03-11 21:03:58 +01:00
|
|
|
int ret, i, acs_ch_list_all = 0;
|
|
|
|
u8 *channels = NULL;
|
|
|
|
unsigned int num_channels = 0;
|
|
|
|
struct hostapd_hw_modes *mode;
|
2015-06-20 02:19:27 +02:00
|
|
|
int *freq_list = NULL;
|
2014-11-18 19:11:09 +01:00
|
|
|
|
|
|
|
if (hapd->driver == NULL || hapd->driver->do_acs == NULL)
|
|
|
|
return 0;
|
2015-03-11 21:03:58 +01:00
|
|
|
|
2014-11-18 19:11:09 +01:00
|
|
|
os_memset(¶ms, 0, sizeof(params));
|
|
|
|
params.hw_mode = hapd->iface->conf->hw_mode;
|
2015-03-11 21:03:58 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If no chanlist config parameter is provided, include all enabled
|
|
|
|
* channels of the selected hw_mode.
|
|
|
|
*/
|
|
|
|
if (!hapd->iface->conf->acs_ch_list.num)
|
|
|
|
acs_ch_list_all = 1;
|
|
|
|
|
|
|
|
mode = hapd->iface->current_mode;
|
2015-06-20 02:19:27 +02:00
|
|
|
if (mode) {
|
|
|
|
channels = os_malloc(mode->num_channels);
|
|
|
|
if (channels == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (i = 0; i < mode->num_channels; i++) {
|
|
|
|
struct hostapd_channel_data *chan = &mode->channels[i];
|
|
|
|
if (!acs_ch_list_all &&
|
|
|
|
!freq_range_list_includes(
|
|
|
|
&hapd->iface->conf->acs_ch_list,
|
|
|
|
chan->chan))
|
|
|
|
continue;
|
|
|
|
if (!(chan->flag & HOSTAPD_CHAN_DISABLED)) {
|
|
|
|
channels[num_channels++] = chan->chan;
|
|
|
|
int_array_add_unique(&freq_list, chan->freq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < hapd->iface->num_hw_features; i++) {
|
|
|
|
mode = &hapd->iface->hw_features[i];
|
|
|
|
hostapd_get_hw_mode_any_channels(hapd, mode,
|
|
|
|
acs_ch_list_all,
|
|
|
|
&freq_list);
|
|
|
|
}
|
2015-03-11 21:03:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
params.ch_list = channels;
|
|
|
|
params.ch_list_len = num_channels;
|
2015-06-20 02:19:27 +02:00
|
|
|
params.freq_list = freq_list;
|
2015-03-11 21:03:58 +01:00
|
|
|
|
2014-11-18 19:11:09 +01:00
|
|
|
params.ht_enabled = !!(hapd->iface->conf->ieee80211n);
|
2014-12-05 00:08:40 +01:00
|
|
|
params.ht40_enabled = !!(hapd->iface->conf->ht_capab &
|
2014-11-18 19:11:09 +01:00
|
|
|
HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET);
|
2015-03-11 21:03:58 +01:00
|
|
|
params.vht_enabled = !!(hapd->iface->conf->ieee80211ac);
|
|
|
|
params.ch_width = 20;
|
|
|
|
if (hapd->iface->conf->ieee80211n && params.ht40_enabled)
|
|
|
|
params.ch_width = 40;
|
|
|
|
|
|
|
|
/* Note: VHT20 is defined by combination of ht_capab & vht_oper_chwidth
|
|
|
|
*/
|
|
|
|
if (hapd->iface->conf->ieee80211ac && params.ht40_enabled) {
|
|
|
|
if (hapd->iface->conf->vht_oper_chwidth == VHT_CHANWIDTH_80MHZ)
|
|
|
|
params.ch_width = 80;
|
|
|
|
else if (hapd->iface->conf->vht_oper_chwidth ==
|
|
|
|
VHT_CHANWIDTH_160MHZ ||
|
|
|
|
hapd->iface->conf->vht_oper_chwidth ==
|
|
|
|
VHT_CHANWIDTH_80P80MHZ)
|
|
|
|
params.ch_width = 160;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = hapd->driver->do_acs(hapd->drv_priv, ¶ms);
|
|
|
|
os_free(channels);
|
|
|
|
|
|
|
|
return ret;
|
2014-11-18 19:11:09 +01:00
|
|
|
}
|