[RFC v2 3/6] hostapd: use extended CSA interface for chan_switch cmd

Bartosz Markowski bartosz.markowski at tieto.com
Fri Jan 31 11:57:01 EST 2014


From: Michal Kazior <michal.kazior at tieto.com>

By default if there are multiple interfaces
running try multi-interface CSA. This is most
likely what the user wants anyway.

Moving a single interface with nl80211 when others
are running wouldn't have worked anyway (assuming
kernel driver supports multi-channel) since
operating frequency is shared across interfaces in
nl80211 backend.

Signed-hostap: Michal Kazior <michal.kazior at tieto.com>
---
 hostapd/ctrl_iface.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index df5c513..eca184b 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1132,16 +1132,28 @@ static int hostapd_ctrl_iface_mgmt_tx(struct hostapd_data *hapd, char *cmd)
 static int hostapd_ctrl_iface_chan_switch(struct hostapd_data *hapd, char *pos)
 {
 #ifdef NEED_AP_MLME
-	struct csa_settings settings;
-	int ret = hostapd_parse_csa_settings(pos, &settings);
+	struct csa_settings settings_def;
+	struct csa_settings *settings;
+	int ret, i;
 
+	ret = hostapd_parse_csa_settings(pos, &settings_def);
 	if (ret)
 		return ret;
 
-	settings.hapd = hapd;
-	settings.priv = hapd->drv_priv;
+	settings = os_malloc(sizeof(*settings) * hapd->iface->num_bss);
+	if (settings == NULL)
+		return -ENOMEM;
 
-	return hostapd_switch_channel(&settings, 1);
+	for (i = 0; i < hapd->iface->num_bss; i++) {
+		memcpy(&settings[i], &settings_def, sizeof(settings_def));
+		settings[i].hapd = hapd->iface->bss[i];
+		settings[i].priv = hapd->iface->bss[i]->drv_priv;
+	}
+
+	ret = hostapd_switch_channel(settings, hapd->iface->num_bss);
+	os_free(settings);
+
+	return ret;
 #else /* NEED_AP_MLME */
 	return -1;
 #endif /* NEED_AP_MLME */
-- 
1.7.9.5



More information about the HostAP mailing list