From patchwork Fri Sep 18 21:06:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 519578 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 76B45140788 for ; Sat, 19 Sep 2015 07:07:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A2EC917C5C2; Fri, 18 Sep 2015 17:07:16 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R162nktvYN05; Fri, 18 Sep 2015 17:07:16 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 90C6317C583; Fri, 18 Sep 2015 17:07:01 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 07E0717C550 for ; Fri, 18 Sep 2015 17:06:56 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bH8lEx4jPQI5 for ; Fri, 18 Sep 2015 17:06:50 -0400 (EDT) Received: from mail2.candelatech.com (mail2.candelatech.com [208.74.158.173]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A17E017C544 for ; Fri, 18 Sep 2015 17:06:50 -0400 (EDT) Received: from localhost.localdomain (firewall.candelatech.com [50.251.239.81]) by mail2.candelatech.com (Postfix) with ESMTP id 1B5B240A5C4; Fri, 18 Sep 2015 14:06:50 -0700 (PDT) From: greearb@candelatech.com To: hostap@lists.shmoo.com Subject: [PATCH 2/3] nl80211: Allow reconfiguring driver-params & refactor. Date: Fri, 18 Sep 2015 17:06:34 -0400 Message-Id: <1442610395-24301-2-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1442610395-24301-1-git-send-email-greearb@candelatech.com> References: <1442610395-24301-1-git-send-email-greearb@candelatech.com> Cc: j@w1.fi, Ben Greear X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Ben Greear 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 --- 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,