From patchwork Tue Jun 5 18:05:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 163120 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A7771B6FCC for ; Wed, 6 Jun 2012 04:05:49 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 810F39D2BC; Tue, 5 Jun 2012 14:05:47 -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 MxqsWM2XGsOk; Tue, 5 Jun 2012 14:05:47 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B2E279D2BD; Tue, 5 Jun 2012 14:05:34 -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 448699D2A1 for ; Tue, 5 Jun 2012 14:05:33 -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 QRrYqBF9+CaN for ; Tue, 5 Jun 2012 14:05:27 -0400 (EDT) Received: from latitanza.investici.org (latitanza.investici.org [82.94.249.234]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "smtp.autistici.org", Issuer "Autistici/Inventati Certification Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id D8F339D2A6 for ; Tue, 5 Jun 2012 14:05:26 -0400 (EDT) Received: from [82.94.249.234] (latitanza [82.94.249.234]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id D514F98B5B; Tue, 5 Jun 2012 18:05:24 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 latitanza.investici.org D514F98B5B From: Antonio Quartulli To: hostap Subject: [PATCH 1/2] wpa_supplicant: add new config params to be used with the ibss join command Date: Tue, 5 Jun 2012 20:05:47 +0200 Message-Id: <1338919548-27278-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.9.4 In-Reply-To: <1338919548-27278-1-git-send-email-ordex@autistici.org> References: <1338919548-27278-1-git-send-email-ordex@autistici.org> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 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 Signed-hostap: Antonio Quartulli --- src/drivers/driver.h | 6 +++ wpa_supplicant/config.c | 96 +++++++++++++++++++++++++++++++++++++++ wpa_supplicant/config_ssid.h | 6 +++ wpa_supplicant/wpa_supplicant.c | 23 +++++++--- 4 files changed, 124 insertions(+), 7 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index f7fb2ef..dda2fbc 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -19,6 +19,7 @@ #define WPA_SUPPLICANT_DRIVER_VERSION 4 +#include "drivers/nl80211_copy.h" #include "common/defs.h" #define HOSTAPD_CHAN_DISABLED 0x00000001 @@ -332,6 +333,11 @@ struct wpa_driver_associate_params { */ int freq; + int beacon_interval; + int fixed_freq; + unsigned char rates[NL80211_MAX_SUPP_RATES]; + int mcast_rate; + /** * bg_scan_period - Background scan period in seconds, 0 to disable * background scan, or -1 to indicate no change to default driver diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index ce763b3..3d6c0e6 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -14,6 +14,7 @@ #include "rsn_supp/wpa.h" #include "eap_peer/eap.h" #include "p2p/p2p.h" +#include "drivers/nl80211_copy.h" #include "config.h" @@ -1436,6 +1437,97 @@ static char * wpa_config_write_p2p_client_list(const struct parse_data *data, #endif /* CONFIG_P2P */ +static int wpa_config_parse_mcast_rate(const struct parse_data *data, + struct wpa_ssid *ssid, int line, + const char *value) +{ + ssid->mcast_rate = (int)(strtod(value, NULL) * 10); + + return 0; +} + +#ifndef NO_CONFIG_WRITE +static char * wpa_config_write_mcast_rate(const struct parse_data *data, + struct wpa_ssid *ssid) +{ + char *value; + int res; + + if (!ssid->mcast_rate == 0) + return NULL; + + value = os_malloc(6); /* longest: 300.0 */ + if (value == NULL) + return NULL; + res = os_snprintf(value, 5, "%.1f", (double)ssid->mcast_rate / 10); + if (res < 0) { + os_free(value); + return NULL; + } + return value; +} +#endif /* NO_CONFIG_WRITE */ + +static int wpa_config_parse_rates(const struct parse_data *data, + struct wpa_ssid *ssid, int line, + const char *value) +{ + int i; + char *pos, *r, *sptr, *end; + double rate; + + pos = (char *)value; + r = strtok_r(pos, ",", &sptr); + i = 0; + while (pos && i < NL80211_MAX_SUPP_RATES) { + rate = 0.0; + if (r) + rate = strtod(r, &end); + ssid->rates[i] = rate * 2; + if (*end != '\0' || rate * 2 != ssid->rates[i]) + return 1; + + i++; + r = strtok_r(NULL, ",", &sptr); + } + + return 0; +} + +#ifndef NO_CONFIG_WRITE +static char * wpa_config_write_rates(const struct parse_data *data, + struct wpa_ssid *ssid) +{ + char *value, *pos; + int res, i; + + if (ssid->rates[0] <= 0) + return NULL; + + value = os_malloc(6 * NL80211_MAX_SUPP_RATES + 1); + if (value == NULL) + return NULL; + pos = value; + for (i = 0; i < NL80211_MAX_SUPP_RATES - 1; i++) { + res = os_snprintf(pos, 6, "%.1f,", (double)ssid->rates[i] / 2); + if (res < 0) { + os_free(value); + return NULL; + } + pos += res; + } + res = os_snprintf(pos, 6, "%.1f", + (double)ssid->rates[NL80211_MAX_SUPP_RATES - 1] / 2); + if (res < 0) { + os_free(value); + return NULL; + } + + value[6 * NL80211_MAX_SUPP_RATES] = '\0'; + return value; +} +#endif /* NO_CONFIG_WRITE */ + /* Helper macros for network block parser */ #ifdef OFFSET @@ -1610,6 +1702,10 @@ static const struct parse_data ssid_fields[] = { { STR(ht_mcs) }, #endif /* CONFIG_HT_OVERRIDES */ { INT(ap_max_inactivity) }, + { INT_RANGE(fixed_freq, 0, 1) }, + { INT_RANGE(beacon_interval, 0, 1000) }, + { FUNC(rates) }, + { FUNC(mcast_rate) }, }; #undef OFFSET diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index 80d4382..8d152a4 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -11,6 +11,7 @@ #include "common/defs.h" #include "eap_peer/eap_config.h" +#include "drivers/nl80211_copy.h" #define MAX_SSID_LEN 32 @@ -499,6 +500,11 @@ struct wpa_ssid { * By default: 300 seconds. */ int ap_max_inactivity; + + int fixed_freq; + int beacon_interval; + unsigned char rates[NL80211_MAX_SUPP_RATES]; + double mcast_rate; }; #endif /* CONFIG_SSID_H */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 3cb954d..59efa16 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1363,15 +1363,24 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, params.ssid_len = ssid->ssid_len; } - if (ssid->mode == WPAS_MODE_IBSS && ssid->bssid_set && - wpa_s->conf->ap_scan == 2) { - params.bssid = ssid->bssid; - params.fixed_bssid = 1; + if (ssid->mode == WPAS_MODE_IBSS) { + if (ssid->bssid_set && wpa_s->conf->ap_scan == 2) { + params.bssid = ssid->bssid; + params.fixed_bssid = 1; + } + if (ssid->frequency > 0 && params.freq == 0) + /* Initial channel for IBSS */ + params.freq = ssid->frequency; + params.fixed_freq = ssid->fixed_freq; + params.beacon_interval = ssid->beacon_interval; + i = 0; + while (i < NL80211_MAX_SUPP_RATES) { + params.rates[i] = ssid->rates[i]; + i++; + } + params.mcast_rate = ssid->mcast_rate; } - if (ssid->mode == WPAS_MODE_IBSS && ssid->frequency > 0 && - params.freq == 0) - params.freq = ssid->frequency; /* Initial channel for IBSS */ params.wpa_ie = wpa_ie; params.wpa_ie_len = wpa_ie_len; params.pairwise_suite = cipher_pairwise;