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

login
register
mail settings
Submitter Bartosz.Markowski@tieto.com
Date Jan. 31, 2014, 4:57 p.m.
Message ID <1391187424-5653-4-git-send-email-bartosz.markowski@tieto.com>
Download mbox | patch
Permalink /patch/315761/
State New
Headers show

Comments

Bartosz.Markowski@tieto.com - Jan. 31, 2014, 4:57 p.m.
From: Michal Kazior <michal.kazior@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@tieto.com>
---
 hostapd/ctrl_iface.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

Patch

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 */