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

login
register
mail settings
Submitter Michal Kazior
Date Jan. 21, 2014, 6:57 a.m.
Message ID <1390287448-7718-4-git-send-email-michal.kazior@tieto.com>
Download mbox | patch
Permalink /patch/312794/
State Superseded
Headers show

Comments

Michal Kazior - Jan. 21, 2014, 6:57 a.m.
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 a73a1d5..e69feae 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1071,16 +1071,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 */