From patchwork Tue Jul 10 16:32:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoni Divinsky X-Patchwork-Id: 170249 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 6C1B42C00DC for ; Wed, 11 Jul 2012 02:39:00 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 42B729C109; Tue, 10 Jul 2012 12:38:57 -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 q7Nl9qWVlUzd; Tue, 10 Jul 2012 12:38:57 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8FCD69C241; Tue, 10 Jul 2012 12:38:50 -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 8D4769C241 for ; Tue, 10 Jul 2012 12:38:49 -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 EPUICp9ozaaP for ; Tue, 10 Jul 2012 12:38:44 -0400 (EDT) Received: from na3sys009aog112.obsmtp.com (na3sys009aog112.obsmtp.com [74.125.149.207]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id ED54C9C109 for ; Tue, 10 Jul 2012 12:38:43 -0400 (EDT) Received: from mail-ob0-f172.google.com ([209.85.214.172]) (using TLSv1) by na3sys009aob112.postini.com ([74.125.148.12]) with SMTP ID DSNKT/xaknCGRNhgC65+hRnh7FoqBBceRBe2@postini.com; Tue, 10 Jul 2012 09:38:44 PDT Received: by obbwc20 with SMTP id wc20so181288obb.31 for ; Tue, 10 Jul 2012 09:38:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=cWWh2y7LDIBa2LZMpjoC6wCHnUgySQJ5BOCkvEHu8oY=; b=peQ4nZkQsznXWDwMDT9q1Yt3krZ9YVo2etodDkIfYr+QY6jamzFzG5uwf4YDL5pqdM 9enrBzsfXes8UtLKDBvfWIeYAVxMLi4S4GYWtTilSO06cE2WiABOO1cMT3raZvTvhNwr CaergJXHVA3tImpg585H9NmbUbTpLe5AsyzCCXQcX+1bwVclnrErirTkS52kd9wejRUG BwNkFbXfrDdVlUcv2V6yrr6ypFKDCHf2MIwOXgI9ByjttGr+TUw6cqiFfMux3smBTU+j jcirUPC+PWpUHPUig7aUlvrr6X2OJFIIlX3/TJcdEhPdMAuI/MMHMH0NZTPghEtEERbm UmUQ== Received: by 10.182.51.37 with SMTP id h5mr4277606obo.35.1341938321968; Tue, 10 Jul 2012 09:38:41 -0700 (PDT) Received: from localhost.localdomain (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id vs8sm33199186obb.14.2012.07.10.09.38.40 (version=SSLv3 cipher=OTHER); Tue, 10 Jul 2012 09:38:41 -0700 (PDT) From: Yoni Divinsky To: Subject: [PATCH] P2P: enable to set in the conf file the wmm params Date: Tue, 10 Jul 2012 19:32:18 +0300 Message-Id: <1341937938-7594-1-git-send-email-yoni.divinsky@ti.com> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQnsLpV24N6/Ye52s1dz6PyBdqdSlBt3SKV/w5IwzAJz7MHjeuIIWHvs78GMiS80w2DuYn+C 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 In case of P2P GO, the wpa_supplicant uses the default hostapd parameters. In the default parameters the ACM bit for video and voice are set to 1, meaning, P2P devices and stations which are connected to the GO cannot pass voice or video data packets. Signed-hostap: Yoni Divinsky --- hostapd/config_file.c | 74 +----------------------------------------- src/ap/ap_config.c | 8 ++-- src/ap/ap_config.h | 10 +----- src/ap/wmm.c | 2 +- src/common/wpa_common.c | 70 +++++++++++++++++++++++++++++++++++++++ src/common/wpa_common.h | 9 +++++ wpa_supplicant/ap.c | 4 ++ wpa_supplicant/config.c | 13 +++++++ wpa_supplicant/config.h | 2 + wpa_supplicant/config_file.c | 18 ++++++++++ 10 files changed, 123 insertions(+), 87 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index eebbaa6..03f82b2 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -909,78 +909,6 @@ static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name, } -static int hostapd_config_wmm_ac(struct hostapd_config *conf, char *name, - char *val) -{ - int num, v; - char *pos; - struct hostapd_wmm_ac_params *ac; - - /* skip 'wme_ac_' or 'wmm_ac_' prefix */ - pos = name + 7; - if (os_strncmp(pos, "be_", 3) == 0) { - num = 0; - pos += 3; - } else if (os_strncmp(pos, "bk_", 3) == 0) { - num = 1; - pos += 3; - } else if (os_strncmp(pos, "vi_", 3) == 0) { - num = 2; - pos += 3; - } else if (os_strncmp(pos, "vo_", 3) == 0) { - num = 3; - pos += 3; - } else { - wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos); - return -1; - } - - ac = &conf->wmm_ac_params[num]; - - if (os_strcmp(pos, "aifs") == 0) { - v = atoi(val); - if (v < 1 || v > 255) { - wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v); - return -1; - } - ac->aifs = v; - } else if (os_strcmp(pos, "cwmin") == 0) { - v = atoi(val); - if (v < 0 || v > 12) { - wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v); - return -1; - } - ac->cwmin = v; - } else if (os_strcmp(pos, "cwmax") == 0) { - v = atoi(val); - if (v < 0 || v > 12) { - wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v); - return -1; - } - ac->cwmax = v; - } else if (os_strcmp(pos, "txop_limit") == 0) { - v = atoi(val); - if (v < 0 || v > 0xffff) { - wpa_printf(MSG_ERROR, "Invalid txop value %d", v); - return -1; - } - ac->txop_limit = v; - } else if (os_strcmp(pos, "acm") == 0) { - v = atoi(val); - if (v < 0 || v > 1) { - wpa_printf(MSG_ERROR, "Invalid acm value %d", v); - return -1; - } - ac->admission_control_mandatory = v; - } else { - wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos); - return -1; - } - - return 0; -} - - #ifdef CONFIG_IEEE80211R static int add_r0kh(struct hostapd_bss_config *bss, char *value) { @@ -2142,7 +2070,7 @@ static int hostapd_config_fill(struct hostapd_config *conf, bss->wmm_uapsd = atoi(pos); } else if (os_strncmp(buf, "wme_ac_", 7) == 0 || os_strncmp(buf, "wmm_ac_", 7) == 0) { - if (hostapd_config_wmm_ac(conf, buf, pos)) { + if (wpa_config_wmm_ac(conf->wmm_ac_params, buf, pos)) { wpa_printf(MSG_ERROR, "Line %d: invalid WMM " "ac item", line); errors++; diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c index 2c633d9..ec9e17d 100644 --- a/src/ap/ap_config.c +++ b/src/ap/ap_config.c @@ -99,13 +99,13 @@ struct hostapd_config * hostapd_config_defaults(void) struct hostapd_config *conf; struct hostapd_bss_config *bss; const int aCWmin = 4, aCWmax = 10; - const struct hostapd_wmm_ac_params ac_bk = + const struct wpa_wmm_ac_params ac_bk = { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */ - const struct hostapd_wmm_ac_params ac_be = + const struct wpa_wmm_ac_params ac_be = { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */ - const struct hostapd_wmm_ac_params ac_vi = /* video traffic */ + const struct wpa_wmm_ac_params ac_vi = /* video traffic */ { aCWmin - 1, aCWmin, 2, 3000 / 32, 1 }; - const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */ + const struct wpa_wmm_ac_params ac_vo = /* voice traffic */ { aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 1 }; const struct hostapd_tx_queue_params txq_bk = { 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 }; diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index ca4fe58..a203599 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -132,14 +132,6 @@ struct hostapd_tx_queue_params { int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */ }; -struct hostapd_wmm_ac_params { - int cwmin; - int cwmax; - int aifs; - int txop_limit; /* in units of 32us */ - int admission_control_mandatory; -}; - #define MAX_ROAMING_CONSORTIUM_LEN 15 @@ -446,7 +438,7 @@ struct hostapd_config { * 2 = VI (video) * 3 = VO (voice) */ - struct hostapd_wmm_ac_params wmm_ac_params[4]; + struct wpa_wmm_ac_params wmm_ac_params[4]; int ht_op_mode_fixed; u16 ht_capab; diff --git a/src/ap/wmm.c b/src/ap/wmm.c index d21c82f..751f9c4 100644 --- a/src/ap/wmm.c +++ b/src/ap/wmm.c @@ -81,7 +81,7 @@ u8 * hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid) /* fill in a parameter set record for each AC */ for (e = 0; e < 4; e++) { struct wmm_ac_parameter *ac = &wmm->ac[e]; - struct hostapd_wmm_ac_params *acp = + struct wpa_wmm_ac_params *acp = &hapd->iconf->wmm_ac_params[e]; ac->aci_aifsn = wmm_aci_aifsn(acp->aifs, diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c index 7a013a8..b339e2e 100644 --- a/src/common/wpa_common.c +++ b/src/common/wpa_common.c @@ -989,6 +989,76 @@ int wpa_compare_rsn_ie(int ft_initial_assoc, return -1; } +int wpa_config_wmm_ac(struct wpa_wmm_ac_params wmm_ac_params[], char *name, + char *val) +{ + int num, v; + char *pos; + struct wpa_wmm_ac_params *ac; + + /* skip 'wme_ac_' or 'wmm_ac_' prefix */ + pos = name + 7; + if (os_strncmp(pos, "be_", 3) == 0) { + num = 0; + pos += 3; + } else if (os_strncmp(pos, "bk_", 3) == 0) { + num = 1; + pos += 3; + } else if (os_strncmp(pos, "vi_", 3) == 0) { + num = 2; + pos += 3; + } else if (os_strncmp(pos, "vo_", 3) == 0) { + num = 3; + pos += 3; + } else { + wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos); + return -1; + } + + ac = &wmm_ac_params[num]; + + if (os_strcmp(pos, "aifs") == 0) { + v = atoi(val); + if (v < 1 || v > 255) { + wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v); + return -1; + } + ac->aifs = v; + } else if (os_strcmp(pos, "cwmin") == 0) { + v = atoi(val); + if (v < 0 || v > 12) { + wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v); + return -1; + } + ac->cwmin = v; + } else if (os_strcmp(pos, "cwmax") == 0) { + v = atoi(val); + if (v < 0 || v > 12) { + wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v); + return -1; + } + ac->cwmax = v; + } else if (os_strcmp(pos, "txop_limit") == 0) { + v = atoi(val); + if (v < 0 || v > 0xffff) { + wpa_printf(MSG_ERROR, "Invalid txop value %d", v); + return -1; + } + ac->txop_limit = v; + } else if (os_strcmp(pos, "acm") == 0) { + v = atoi(val); + if (v < 0 || v > 1) { + wpa_printf(MSG_ERROR, "Invalid acm value %d", v); + return -1; + } + ac->admission_control_mandatory = v; + } else { + wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos); + return -1; + } + + return 0; +} #ifdef CONFIG_IEEE80211R int wpa_insert_pmkid(u8 *ies, size_t ies_len, const u8 *pmkid) diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h index 6b50997..a553b2f 100644 --- a/src/common/wpa_common.h +++ b/src/common/wpa_common.h @@ -296,6 +296,13 @@ struct rsn_rdie { #pragma pack(pop) #endif /* _MSC_VER */ +struct wpa_wmm_ac_params { + int cwmin; + int cwmax; + int aifs; + int txop_limit; /* in units of 32us */ + int admission_control_mandatory; +}; int wpa_eapol_key_mic(const u8 *key, int ver, const u8 *buf, size_t len, u8 *mic); @@ -375,4 +382,6 @@ struct wpa_ft_ies { int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse); +int wpa_config_wmm_ac(struct wpa_wmm_ac_params wmm_ac_params[], char *name, + char *val); #endif /* WPA_COMMON_H */ diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index f9e0045..c4daf18 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -491,6 +491,10 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s, return -1; } + os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params, + wpa_s->conf->wmm_ac_params, + sizeof(wpa_s->conf->wmm_ac_params)); + if (params.uapsd > 0) { conf->bss->wmm_enabled = 1; conf->bss->wmm_uapsd = 1; diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index a68b31e..d7979ff 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2488,6 +2488,15 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, const char *driver_param) { struct wpa_config *config; + const int aCWmin = 4, aCWmax = 10; + const struct wpa_wmm_ac_params ac_bk = + { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */ + const struct wpa_wmm_ac_params ac_be = + { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */ + const struct wpa_wmm_ac_params ac_vi = /* video traffic */ + { aCWmin - 1, aCWmin, 2, 3000 / 32, 1 }; + const struct wpa_wmm_ac_params ac_vo = /* voice traffic */ + { aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 1 }; config = os_zalloc(sizeof(*config)); if (config == NULL) @@ -2502,6 +2511,10 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT; config->max_num_sta = DEFAULT_MAX_NUM_STA; config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE; + config->wmm_ac_params[0] = ac_be; + config->wmm_ac_params[1] = ac_bk; + config->wmm_ac_params[2] = ac_vi; + config->wmm_ac_params[3] = ac_vo; if (ctrl_interface) config->ctrl_interface = os_strdup(ctrl_interface); diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 46c4da2..19c0d2b 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -26,6 +26,7 @@ #include "config_ssid.h" #include "wps/wps.h" +#include "common/wpa_common.h" struct wpa_cred { @@ -517,6 +518,7 @@ struct wpa_config { struct p2p_channel *p2p_pref_chan; struct wpabuf *wps_vendor_ext_m1; + struct wpa_wmm_ac_params wmm_ac_params[4]; #define MAX_WPS_VENDOR_EXT 10 /** diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 8badc7b..55cb5fd 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -382,6 +382,24 @@ struct wpa_config * wpa_config_read(const char *name) continue; } #endif /* CONFIG_NO_CONFIG_BLOBS */ +#ifdef CONFIG_P2P + } else if (os_strncmp(buf, "wme_ac_", 7) == 0 || + os_strncmp(buf, "wmm_ac_", 7) == 0) { + pos = os_strchr(buf, '='); + if (pos == NULL) { + wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'", + line, buf); + errors++; + continue; + } + *pos = '\0'; + pos++; + if (wpa_config_wmm_ac(config->wmm_ac_params, buf, pos)) { + wpa_printf(MSG_ERROR, "Line %d: invalid WMM " + "ac item", line); + errors++; + } +#endif /* CONFIG_P2P */ } else if (wpa_config_process_global(config, pos, line) < 0) { wpa_printf(MSG_ERROR, "Line %d: Invalid configuration " "line '%s'.", line, pos);