[PATCH] madwifi: RSN capability mismatch when WMM enabled

Masashi Honma honma
Thu Mar 26 02:27:23 PDT 2009


> When I have some time, I will make like "get_rsn_capabilty" function
> and test all bit includes peerkey and 11w.

I made it.


diff --git a/hostapd/driver_madwifi.c b/hostapd/driver_madwifi.c
index a40f731..dc8efee 100644
--- a/hostapd/driver_madwifi.c
+++ b/hostapd/driver_madwifi.c
@@ -285,11 +285,8 @@ madwifi_configure_wpa(struct madwifi_driver_data *drv)
 		return -1;
 	}
 
-	v = 0;
-	if (conf->rsn_preauth)
-		v |= BIT(0);
-	wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x",
-		   __func__, conf->rsn_preauth);
+	v = get_rsn_capabilities_by_bss_conf(conf);
+	wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x", __func__, v);
 	if (set80211param(drv, IEEE80211_PARAM_RSNCAPS, v)) {
 		printf("Unable to set RSN capabilities to 0x%x\n", v);
 		return -1;
diff --git a/hostapd/hostapd.c b/hostapd/hostapd.c
index 6a04713..5b920ed 100644
--- a/hostapd/hostapd.c
+++ b/hostapd/hostapd.c
@@ -45,6 +45,7 @@
 #include "l2_packet/l2_packet.h"
 #include "wps_hostapd.h"
 #include "tkip_countermeasures.h"
+#include "wpa_auth_i.h"
 
 
 static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
@@ -257,6 +258,16 @@ static void hostapd_wpa_auth_conf(struct hostapd_bss_config *conf,
 }
 
 
+u16 get_rsn_capabilities_by_bss_conf(struct hostapd_bss_config *conf)
+{
+	struct wpa_auth_config auth_conf;
+
+	hostapd_wpa_auth_conf(conf, &auth_conf);
+
+	return get_rsn_capabilities(&auth_conf);
+}
+
+
 int hostapd_reload_config(struct hostapd_iface *iface)
 {
 	struct hostapd_data *hapd = iface->bss[0];
diff --git a/hostapd/hostapd.h b/hostapd/hostapd.h
index c7b1947..8cbe21f 100644
--- a/hostapd/hostapd.h
+++ b/hostapd/hostapd.h
@@ -156,6 +156,7 @@ struct hostapd_iface {
 #endif /* CONFIG_IEEE80211N */
 };
 
+u16 get_rsn_capabilities_by_bss_conf(struct hostapd_bss_config *conf);
 int hostapd_reload_config(struct hostapd_iface *iface);
 int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
 					 void *ctx), void *ctx);
diff --git a/hostapd/wpa_auth_i.h b/hostapd/wpa_auth_i.h
index bcaeda5..21e438c 100644
--- a/hostapd/wpa_auth_i.h
+++ b/hostapd/wpa_auth_i.h
@@ -181,6 +181,7 @@ struct wpa_authenticator {
 };
 
 
+u16 get_rsn_capabilities(struct wpa_auth_config *conf);
 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
 		     const u8 *pmkid);
 void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
diff --git a/hostapd/wpa_auth_ie.c b/hostapd/wpa_auth_ie.c
index b56280f..b74c506 100644
--- a/hostapd/wpa_auth_ie.c
+++ b/hostapd/wpa_auth_ie.c
@@ -108,13 +108,37 @@ static int wpa_write_wpa_ie(struct wpa_auth_config *conf, u8 *buf, size_t len)
 }
 
 
+u16 get_rsn_capabilities(struct wpa_auth_config *conf)
+{
+	u16 capab;
+
+	capab = 0;
+	if (conf->rsn_preauth)
+		capab |= WPA_CAPABILITY_PREAUTH;
+	if (conf->peerkey)
+		capab |= WPA_CAPABILITY_PEERKEY_ENABLED;
+	if (conf->wmm_enabled) {
+		/* 4 PTKSA replay counters when using WMM */
+		capab |= (RSN_NUM_REPLAY_COUNTERS_16 << 2);
+	}
+#ifdef CONFIG_IEEE80211W
+	if (conf->ieee80211w != WPA_NO_IEEE80211W) {
+		capab |= WPA_CAPABILITY_MFPC;
+		if (conf->ieee80211w == IEEE80211W_REQUIRED)
+			capab |= WPA_CAPABILITY_MFPR;
+	}
+#endif /* CONFIG_IEEE80211W */
+
+	return capab;
+}
+
+
 int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
 		     const u8 *pmkid)
 {
 	struct rsn_ie_hdr *hdr;
 	int num_suites;
 	u8 *pos, *count;
-	u16 capab;
 
 	hdr = (struct rsn_ie_hdr *) buf;
 	hdr->elem_id = WLAN_EID_RSN;
@@ -210,23 +234,7 @@ int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
 	WPA_PUT_LE16(count, num_suites);
 
 	/* RSN Capabilities */
-	capab = 0;
-	if (conf->rsn_preauth)
-		capab |= WPA_CAPABILITY_PREAUTH;
-	if (conf->peerkey)
-		capab |= WPA_CAPABILITY_PEERKEY_ENABLED;
-	if (conf->wmm_enabled) {
-		/* 4 PTKSA replay counters when using WMM */
-		capab |= (RSN_NUM_REPLAY_COUNTERS_16 << 2);
-	}
-#ifdef CONFIG_IEEE80211W
-	if (conf->ieee80211w != WPA_NO_IEEE80211W) {
-		capab |= WPA_CAPABILITY_MFPC;
-		if (conf->ieee80211w == IEEE80211W_REQUIRED)
-			capab |= WPA_CAPABILITY_MFPR;
-	}
-#endif /* CONFIG_IEEE80211W */
-	WPA_PUT_LE16(pos, capab);
+	WPA_PUT_LE16(pos, get_rsn_capabilities(conf));
 	pos += 2;
 
 	if (pmkid) {


Regards,
Masashi Honma.



More information about the Hostap mailing list