Patchwork wpa_supplicant: Fix AP mode frequency initialization

login
register
mail settings
Submitter Ilan Peer
Date Aug. 7, 2013, 10:08 a.m.
Message ID <1375870125-27991-7-git-send-email-ilan.peer@intel.com>
Download mbox | patch
Permalink /patch/265475/
State Accepted
Commit 973622cd440505a22a1890040931579b5f8f1ac4
Headers show

Comments

Ilan Peer - Aug. 7, 2013, 10:08 a.m.
From: Avraham Stern <avraham.stern@intel.com>

In AP mode the frequency was initialized only after trying to set up
the AP which caused failure. Move AP frequency initialization to
the right place.

Signed-hostap: Avraham Stern <avraham.stern@intel.com>
---
 wpa_supplicant/ap.c |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
Jouni Malinen - Aug. 25, 2013, 8:26 a.m.
On Wed, Aug 07, 2013 at 01:08:43PM +0300, Ilan Peer wrote:
> In AP mode the frequency was initialized only after trying to set up
> the AP which caused failure. Move AP frequency initialization to
> the right place.

Thanks, applied. The previous behavior was actually pretty much assumed
to be by design to reject AP mode configuration blocks without the
frequency specified. Anyway, I guess it's fine to change this especially
with the command in wpa_supplicant_conf_ap() talking about a default
channel.

Patch

diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index c48a286..c8fc098 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -51,18 +51,12 @@  static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
 
 	os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));
 
-	if (ssid->frequency == 0) {
-		/* default channel 11 */
-		conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
-		conf->channel = 11;
-	} else {
-		conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
-						       &conf->channel);
-		if (conf->hw_mode == NUM_HOSTAPD_MODES) {
-			wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: "
-				   "%d MHz", ssid->frequency);
-			return -1;
-		}
+	conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
+					       &conf->channel);
+	if (conf->hw_mode == NUM_HOSTAPD_MODES) {
+		wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: "
+			   "%d MHz", ssid->frequency);
+		return -1;
 	}
 
 	/* TODO: enable HT40 if driver supports it;
@@ -461,6 +455,8 @@  int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
 		params.mode = IEEE80211_MODE_AP;
 		break;
 	}
+	if (ssid->frequency == 0)
+		ssid->frequency = 2462; /*default channel 11*/
 	params.freq = ssid->frequency;
 
 	params.wpa_proto = ssid->proto;