[PATCH 2/3] nl80211: Allow reconfiguring driver-params & refactor.

greearb at candelatech.com greearb
Fri Sep 18 14:06:34 PDT 2015


From: Ben Greear <greearb at candelatech.com>

Refactor the legacy-rate config building code a bit so it
can be called by other code.

Allow re-configuring the driver-params on .conf reload.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
 src/drivers/driver_nl80211.c    | 136 +++++++++++++++++++++++-----------------
 src/drivers/driver_nl80211.h    |   2 +
 wpa_supplicant/wpa_supplicant.c |  18 ++++++
 3 files changed, 99 insertions(+), 57 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index d0592c2..73039ad 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -6360,6 +6360,75 @@ static int wpa_driver_nl80211_probe_req_report(struct i802_bss *bss, int report)
 	return -1;
 }
 
+/* Returns count.  Zero return means use defaults (ie, all rates).
+ */
+int nl80211_build_legacy_rateset(unsigned int legacy_rates, int b_disabled,
+				 unsigned char* rates)
+{
+	int i = 0;
+	if (legacy_rates & (1<<31)) {
+		/* Pay attention to the legacy mask */
+		if (!(b_disabled || ((legacy_rates & 0x1) == 0))) {
+			rates[i] = 2;
+			i++;
+		}
+		if (!(b_disabled || ((legacy_rates & 0x2) == 0))) {
+			rates[i] = 4;
+			i++;
+		}
+		if (!(b_disabled || ((legacy_rates & 0x4) == 0))) {
+			rates[i] = 11;
+			i++;
+		}
+		if (!(b_disabled || ((legacy_rates & 0x8) == 0))) {
+			rates[i] = 22;
+			i++;
+		}
+		if (legacy_rates & 0x10) { // 6Mbps
+			rates[i] = 12;
+			i++;
+		}
+		if (legacy_rates & 0x20) { // 9Mbps
+			rates[i] = 18;
+			i++;
+		}
+		if (legacy_rates & 0x40) { // 12Mbps
+			rates[i] = 24;
+			i++;
+		}
+		if (legacy_rates & 0x80) { // 18Mbps
+			rates[i] = 36;
+			i++;
+		}
+		if (legacy_rates & 0x100) { // 24Mbps
+			rates[i] = 48;
+			i++;
+		}
+		if (legacy_rates & 0x200) { // 36Mbps
+			rates[i] = 72;
+			i++;
+		}
+		if (legacy_rates & 0x400) { // 48Mbps
+			rates[i] = 96;
+			i++;
+		}
+		if (legacy_rates & 0x800) { // 54Mbps
+			rates[i] = 108;
+			i++;
+		}
+	}/* if user configured a legacy mask */
+	else if (b_disabled) {
+		i = 8;
+		/* Enable all /g rates */
+		memcpy(rates, "\x0c\x12\x18\x24\x30\x48\x60\x6c", i);
+	}
+	else {
+		/* Enable all /b/g rates */
+		i = 12;
+		memcpy(rates, "\x02\x04\x0b\x16\x0c\x12\x18\x24\x30\x48\x60\x6c", 12);
+	}
+	return i;
+}
 
 static int nl80211_set_legacy_rates(struct i802_bss *bss,
 				    struct wpa_driver_nl80211_data *drv,
@@ -6398,63 +6467,7 @@ static int nl80211_set_legacy_rates(struct i802_bss *bss,
 
 	if (legacy_rates & (1<<31) || b_disabled) {
 		unsigned char rates[12];
-		int i = 0;
-		if (legacy_rates & (1<<31)) {
-			/* Pay attention to the legacy mask */
-			if (!(b_disabled || ((legacy_rates & 0x1) == 0))) {
-				rates[i] = 2;
-				i++;
-			}
-			if (!(b_disabled || ((legacy_rates & 0x2) == 0))) {
-				rates[i] = 4;
-				i++;
-			}
-			if (!(b_disabled || ((legacy_rates & 0x4) == 0))) {
-				rates[i] = 11;
-				i++;
-			}
-			if (!(b_disabled || ((legacy_rates & 0x8) == 0))) {
-				rates[i] = 22;
-				i++;
-			}
-			if (legacy_rates & 0x10) { // 6Mbps
-				rates[i] = 12;
-				i++;
-			}
-			if (legacy_rates & 0x20) { // 9Mbps
-				rates[i] = 18;
-				i++;
-			}
-			if (legacy_rates & 0x40) { // 12Mbps
-				rates[i] = 24;
-				i++;
-			}
-			if (legacy_rates & 0x80) { // 18Mbps
-				rates[i] = 36;
-				i++;
-			}
-			if (legacy_rates & 0x100) { // 24Mbps
-				rates[i] = 48;
-				i++;
-			}
-			if (legacy_rates & 0x200) { // 36Mbps
-				rates[i] = 72;
-				i++;
-			}
-			if (legacy_rates & 0x400) { // 48Mbps
-				rates[i] = 96;
-				i++;
-			}
-			if (legacy_rates & 0x800) { // 54Mbps
-				rates[i] = 108;
-				i++;
-			}
-		}/* if user configured a legacy mask */
-		else if (b_disabled) {
-			i = 8;
-			/* Enable all /g rates */
-			memcpy(rates, "\x0c\x12\x18\x24\x30\x48\x60\x6c", i);
-		}
+		int i = nl80211_build_legacy_rateset(legacy_rates, b_disabled, rates);
 		if (legacy_rates & (1<<31) || i) {
 			if (nla_put(msg, NL80211_TXRATE_LEGACY, i, rates))
 				goto fail;
@@ -6729,7 +6742,13 @@ static int nl80211_set_param(void *priv, const char *param)
 	if (os_strstr(param, "use_monitor=1")) {
 		drv->use_monitor = 1;
 	}
+	else {
+		drv->use_monitor = 0;
+	}
 
+	/* Not sure if it is safe to just back this out if param changes, so
+	 * this and similar are not changeable once value is enabled. --Ben
+	 */
 	if (os_strstr(param, "force_connect_cmd=1")) {
 		drv->capa.flags &= ~WPA_DRIVER_FLAGS_SME;
 		drv->force_connect_cmd = 1;
@@ -6740,6 +6759,9 @@ static int nl80211_set_param(void *priv, const char *param)
 		drv->test_use_roc_tx = 1;
 	}
 
+	bss->legacy_rates = 0;
+	bss->disable_ht = 0;
+	bss->disable_vht = 0;
 	if ((tmp = os_strstr(param, "legacy_rates="))) {
 		bss->legacy_rates = atoi(tmp + strlen("legacy_rates="));
 		bss->legacy_rates |= (1<<31); /* so we know user actually configured something */
diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
index 3eecc9a..d064f75 100644
--- a/src/drivers/driver_nl80211.h
+++ b/src/drivers/driver_nl80211.h
@@ -266,6 +266,8 @@ struct nl80211_bss_info_arg {
 };
 
 int bss_info_handler(struct nl_msg *msg, void *arg);
+int nl80211_build_legacy_rateset(unsigned int legacy_rates, int b_disabled,
+				 unsigned char* rates);
 void wpa_driver_nl80211_scan_timeout(void *eloop_ctx, void *timeout_ctx);
 int wpa_driver_nl80211_scan(struct i802_bss *bss,
 			    struct wpa_driver_scan_params *params);
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 09c9371..12b84e4 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -949,6 +949,7 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
 	struct wpa_config *conf;
 	int reconf_ctrl;
 	int old_ap_scan;
+	int set_driver_param = 0;
 
 	if (wpa_s->confname == NULL)
 		return -1;
@@ -962,6 +963,23 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
 
 	conf->changed_parameters = (unsigned int) -1;
 
+	if (wpa_s->conf->driver_param) {
+		if ((!conf->driver_param) ||
+		    os_strcmp(conf->driver_param, wpa_s->conf->driver_param))
+		    set_driver_param = 1;
+	}
+	else {
+		if (conf->driver_param)
+			set_driver_param = 1;
+	}
+	if (set_driver_param) {
+		if (wpa_drv_set_param(wpa_s, conf->driver_param) < 0) {
+			wpa_msg(wpa_s, MSG_ERROR, "Driver interface rejected "
+				"driver_param '%s'", conf->driver_param);
+			return -1;
+		}
+	}
+
 	reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
 		|| (conf->ctrl_interface && wpa_s->conf->ctrl_interface &&
 		    os_strcmp(conf->ctrl_interface,
-- 
1.9.3




More information about the Hostap mailing list