[PATCH v2] ibss: add WPA_DRIVER_FLAGS_HT_IBSS

Janusz Dziedzic janusz.dziedzic
Wed Jan 7 00:29:43 PST 2015


Add WPA_DRIVER_FLAGS_HT_IBSS driver feature flag.
Some drivers could not set this feature and next could
fail when we will enable HT support for IBSS with error message:
nl80211: Join IBSS failed: ret=-22 (Invalid argument)

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 src/drivers/driver.h              |  2 ++
 src/drivers/driver_nl80211_capa.c |  3 +++
 wpa_supplicant/wpa_supplicant.c   | 48 ++++++++++++++++++++++++++-------------
 3 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index b8ee825..60edc50 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1079,6 +1079,8 @@ struct wpa_driver_capa {
 #define WPA_DRIVER_FLAGS_ACS_OFFLOAD		0x0000000200000000ULL
 /* Driver supports key management offload */
 #define WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD	0x0000000400000000ULL
+/* Driver supports IBSS with HT datarates */
+#define WPA_DRIVER_FLAGS_HT_IBSS		0x0000000800000000ULL
 	u64 flags;
 
 #define WPA_DRIVER_SMPS_MODE_STATIC			0x00000001
diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c
index 657f38c..8c19937 100644
--- a/src/drivers/driver_nl80211_capa.c
+++ b/src/drivers/driver_nl80211_capa.c
@@ -381,6 +381,9 @@ static void wiphy_info_feature_flags(struct wiphy_info_data *info,
 
 	if (flags & NL80211_FEATURE_TX_POWER_INSERTION)
 		capa->rrm_flags |= WPA_DRIVER_FLAGS_TX_POWER_INSERTION;
+
+	if (flags & NL80211_FEATURE_HT_IBSS)
+		capa->flags |= WPA_DRIVER_FLAGS_HT_IBSS;
 }
 
 
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 995c8d8..1f29bb9 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1595,6 +1595,36 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
 	}
 }
 
+static void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, struct hostapd_freq_params *freq)
+{
+	enum hostapd_hw_mode hw_mode;
+	struct hostapd_hw_modes *mode = NULL;
+	u8 channel;
+	int i;
+
+	freq->freq = ssid->frequency;
+
+	/* For IBSS check HT_IBSS flag */
+	if (ssid->mode == WPAS_MODE_IBSS &&
+	    !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_HT_IBSS))
+		return;
+
+	hw_mode = ieee80211_freq_to_chan(ssid->frequency, &channel);
+	for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) {
+		if (wpa_s->hw.modes[i].mode == hw_mode) {
+			mode = &wpa_s->hw.modes[i];
+			break;
+		}
+	}
+
+	if (!mode)
+		return;
+
+	freq->ht_enabled = ht_supported(mode);
+
+	return;
+}
+
 
 static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
 {
@@ -1909,23 +1939,9 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
 
 	/* Initial frequency for IBSS/mesh */
 	if ((ssid->mode == WPAS_MODE_IBSS || ssid->mode == WPAS_MODE_MESH) &&
-	    ssid->frequency > 0 && params.freq.freq == 0) {
-		enum hostapd_hw_mode hw_mode;
-		u8 channel;
-
-		params.freq.freq = ssid->frequency;
+	    ssid->frequency > 0 && params.freq.freq == 0)
+		ibss_mesh_setup_freq(wpa_s, ssid, &params.freq);
 
-		hw_mode = ieee80211_freq_to_chan(ssid->frequency, &channel);
-		for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) {
-			if (wpa_s->hw.modes[i].mode == hw_mode) {
-				struct hostapd_hw_modes *mode;
-
-				mode = &wpa_s->hw.modes[i];
-				params.freq.ht_enabled = ht_supported(mode);
-				break;
-			}
-		}
-	}
 
 	if (ssid->mode == WPAS_MODE_IBSS) {
 		if (ssid->beacon_int)
-- 
1.9.1




More information about the Hostap mailing list