From patchwork Sun Jun 28 15:57:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Bar X-Patchwork-Id: 1318607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=celeno.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=yh9YbJ36; dkim=temperror header.d=celeno.com header.i=@celeno.com header.a=rsa-sha256 header.s=selector2 header.b=ZIc1TJGK; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49vwLK3Jxpz9sDX for ; Mon, 29 Jun 2020 01:59:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=C6/McMG3vO/9r5stxQSVho1iZt1wjcza3MJeCdTVPaY=; b=yh9YbJ36v5bVCK6r8vrcB4Oc80 zxiX/eb8NooJ0F1Tpv/4+TDmzh2fgViQd1U0DZ850y58Noc7RMMeLlw7Pvt0Mqa2/2SdSrogtfqO/ Un97baoHdvNiFu9DKNGXhN5qegjaBBun0BxjrInTPcJ27hhaNfC1FPHo5doqocIru0VvawzIyoJQu pgCr/XXYBuakcLXuBT4tEb0HE5u0On6w6WUiHAU3dzk2lRoPf20aT1KJPz3Wv+oJD+47K6RztB+ou ruL7AiqupCSKPOSChWJFBl/U30QaGJ6UVWeGWm3JXK0Ggb8+0K1hEoPzbs2Q9JhhhCzAEFedbyNvj tbWaKPFQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpZgy-0007O2-3N; Sun, 28 Jun 2020 15:58:04 +0000 Received: from mail-eopbgr20051.outbound.protection.outlook.com ([40.107.2.51] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jpZgu-0007Mp-86 for hostap@lists.infradead.org; Sun, 28 Jun 2020 15:58:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fqoiMM9BW8VQIMEKcver9nkE7k87q36avMUNId9wn3sVgqSXaVg3cqDg3GnwHBtmjKdUpwQF+atehUVBk0zaavqF+eeURJrgMOH2dymic0kTozzaM4TaclvLs9yxvvwtbyxr1Ge2VOOx1CVSBG5saNxrBlKFKCPHgNug7q0YDozaPrwcL04EyAyLeon2qazK8chm1aacC++2nMnpzVmMI9D/tW6wfLmjoS8L9AuqgmlvxTIk8xHSLEZ83qrEoNpdEsjQrFSdB1EDN2Wlcmzvkm3lUss0klmoXCXFXOeVr5Ch3nP/6SUUZhbReO2tohdm5f7u6TJFw8LzPKBeOo69Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fy7G0xluKUVaUsL1xqMbmEmJTy/0Ugf2gcj5o4xMB9M=; b=lV7H/zE3cRBRPfhcDuVPzAaYNaV5cMq9/o7uJzvbnc7Xy6BnoF+VrrDpOI4hgIUgPJwginumngj1ecu5JUpLOW6YiXPqv9BAJgyOzO61l7UP16/ffI1kpJPyyIwu2Jr4JusFYulT9/zispLvFv74JhoY/YH0XsYUvwGld8rsk4rC+7cQL+AJJtTO4dMPnZTTgTlG/EqC6N7ZuUYFzXf/0Y/YBBBo80IGgFK6SpgixYkXwbzeJycXoEcwLFWL7HU+pd0QK+DNATLZ1mMJNhVB3MoEe8m6nuuI9Ep1+OpOnUYIBcyMkppS/7IGBn2aPq/a9kxLTfxrWbXXEnQ9pDEd6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=celeno.com; dmarc=pass action=none header.from=celeno.com; dkim=pass header.d=celeno.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=celeno.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fy7G0xluKUVaUsL1xqMbmEmJTy/0Ugf2gcj5o4xMB9M=; b=ZIc1TJGKIWWDRNuPcIAMZbT34MZhT0O7MGJ1LR04J4nFKB6qSAaXSY5Fq8VfgEgGi/cwp0/1RfJdvSHTkrl+v/yTVwN6LU0yLqinY1YHoLyWhNkV9bGR7TNALuEtlFeh063DSmgV3UEbf/hF06iFZZf59+lK428YdBLLE7aNkXk= Authentication-Results: w1.fi; dkim=none (message not signed) header.d=none;w1.fi; dmarc=none action=none header.from=celeno.com; Received: from AM0P192MB0468.EURP192.PROD.OUTLOOK.COM (2603:10a6:208:45::15) by AM0P192MB0385.EURP192.PROD.OUTLOOK.COM (2603:10a6:208:43::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Sun, 28 Jun 2020 15:57:48 +0000 Received: from AM0P192MB0468.EURP192.PROD.OUTLOOK.COM ([fe80::5cae:415:1979:1de1]) by AM0P192MB0468.EURP192.PROD.OUTLOOK.COM ([fe80::5cae:415:1979:1de1%5]) with mapi id 15.20.3131.026; Sun, 28 Jun 2020 15:57:47 +0000 From: Shay Bar To: Jouni Malinen Subject: [PATCH] hostapd: Set Basic/Supported rates per BSS Date: Sun, 28 Jun 2020 18:57:16 +0300 Message-Id: <20200628155716.28880-1-shay.bar@celeno.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: LO2P265CA0380.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::32) To AM0P192MB0468.EURP192.PROD.OUTLOOK.COM (2603:10a6:208:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (87.71.73.65) by LO2P265CA0380.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Sun, 28 Jun 2020 15:57:46 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [87.71.73.65] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c083e0b-b0ba-48d2-cca2-08d81b7c00b7 X-MS-TrafficTypeDiagnostic: AM0P192MB0385: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:565; X-Forefront-PRVS: 0448A97BF2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ov8DQ1qQyHWop1yzyELPM3Ket1WEIikvxDWlPsmlAkpGIb5tz2WBF+5utApo6A5zKh9AX0WzB4ufBzwDZMeV70nuCU3r/Yj+Ex44XSiUK3mWzaaDtOpWnU1QPX7n6x+T7pu2KXlMGYEL0gDqxNSi2EEB++hG8ihzUMUONsdAmFWuWXqdnDXuFX6LPnaCtt03XAonPy/xah8fwTXI6S2bT9mcIbn4Eect6ggySVKjb230DxoGx55N9jwXZztbG8/A3ZcXddtP8gQp3u2qf/ga5QNoF4lj3lOGXFVOD0Uwx/Nw/e7zJ/A0TjYbfZyMl7QV1zRy+OJ9SH/+B7mQzQU10IBphhPPeGoi6CUfPoC2BAUdqSh4Qznpi8WYuRxWvkeZ8yqymLT5NEN7QlPTiUf2KA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0P192MB0468.EURP192.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(366004)(396003)(346002)(136003)(39840400004)(376002)(107886003)(1076003)(52116002)(30864003)(86362001)(6506007)(6916009)(2616005)(956004)(6512007)(44832011)(83380400001)(4326008)(6666004)(69590400007)(2906002)(478600001)(186003)(26005)(8676002)(66946007)(8936002)(5660300002)(66556008)(66476007)(6486002)(36756003)(316002)(16526019)(781001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eI0/bnad/JwdLtuqG7BjL4L52KLUu9TDDt5csyBEM67qd2nYJXU1/7UOStwggSJGRNUOm7X9kPag0OHtbWF+twFD4cMDDWVMy0Gx4FWj3Zd/qQjPggOCAZnQ7mriv3uiAcDFgTrv4AK1BSVsFSKyuCGy4viVm/3rTjf7UXXc1JjBTNnmtIXcPWbDeOi2gb/myiz3x0c3bBnAuEYlCl/MTeYIaG3Rq7hS7nbi2f6yFBVeZpATxW0Pk+xbOb1VlREAICz+ogjetDoyM50vs4I/fKYyxipc3bnJB/b73/LiTItq+2/C+JHcRVHvf46s1KBymKSnkFEuai5Ua8UO7mvF71nmYwyI2m1C3DwYuKUcdBfXlINTFR8qna8W1FwccouT+I1kJSsZScPc2adjk3yEZ5c4FBO+IOKrOEkHWgLvz0QPN6q2yZAtHTfBic3n7bQ0MtiW+J9OnIbwC0G3b5o4iJgDElT+inDnZMfBU+w0mEg= X-OriginatorOrg: celeno.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c083e0b-b0ba-48d2-cca2-08d81b7c00b7 X-MS-Exchange-CrossTenant-AuthSource: AM0P192MB0468.EURP192.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2020 15:57:47.7893 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f313103b-4c9f-4fd3-b5cf-b97f91c4afa8 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MeK2rxcGpeLrvlTfHax+r+5gKycexHq3K1PFOwtgFghv/ZE3o6YZTSkDX2KJNyb+BBCzDMHuZwaGG3qjTyr92Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0P192MB0385 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.2.51 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.2.51 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shay.bar@celeno.com, hostap@lists.infradead.org, eliav.farber@celeno.com Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In case of MBSS, there is a need to be able to control the Basic/Supported rates per BSS. This patch adds that support. Signed-off-by: Shay Bar --- hostapd/config_file.c | 4 +- src/ap/ap_config.c | 4 +- src/ap/ap_config.h | 5 +- src/ap/beacon.c | 2 +- src/ap/ctrl_iface_ap.c | 6 +-- src/ap/hostapd.c | 109 +++++++++++++++++++++++++++++++++++------ src/ap/hostapd.h | 9 ++-- src/ap/hw_features.c | 79 ----------------------------- src/ap/hw_features.h | 8 --- src/ap/ieee802_11.c | 20 ++++---- src/ap/sta_info.c | 6 +-- wpa_supplicant/ap.c | 4 +- wpa_supplicant/mesh.c | 14 +++--- 13 files changed, 131 insertions(+), 139 deletions(-) -- 2.17.1 diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 1c72e5578..0be63941b 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -3280,13 +3280,13 @@ static int hostapd_config_fill(struct hostapd_config *conf, } bss->send_probe_response = val; } else if (os_strcmp(buf, "supported_rates") == 0) { - if (hostapd_parse_intlist(&conf->supported_rates, pos)) { + if (hostapd_parse_intlist(&bss->supported_rates, pos)) { wpa_printf(MSG_ERROR, "Line %d: invalid rate list", line); return 1; } } else if (os_strcmp(buf, "basic_rates") == 0) { - if (hostapd_parse_intlist(&conf->basic_rates, pos)) { + if (hostapd_parse_intlist(&bss->basic_rates, pos)) { wpa_printf(MSG_ERROR, "Line %d: invalid rate list", line); return 1; diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c index 35a32a130..9b5ff82f4 100644 --- a/src/ap/ap_config.c +++ b/src/ap/ap_config.c @@ -794,6 +794,8 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf) os_free(conf->radius_das_shared_secret); hostapd_config_free_vlan(conf); os_free(conf->time_zone); + os_free(conf->supported_rates); + os_free(conf->basic_rates); #ifdef CONFIG_IEEE80211R_AP { @@ -965,8 +967,6 @@ void hostapd_config_free(struct hostapd_config *conf) for (i = 0; i < conf->num_bss; i++) hostapd_config_free_bss(conf->bss[i]); os_free(conf->bss); - os_free(conf->supported_rates); - os_free(conf->basic_rates); os_free(conf->acs_ch_list.range); os_free(conf->acs_freq_list.range); os_free(conf->driver_params); diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index cffa636cc..41ea47f26 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -322,6 +322,9 @@ struct hostapd_bss_config { struct hostapd_ssid ssid; + int *supported_rates; + int *basic_rates; + char *eap_req_id_text; /* optional displayable message sent with * EAP Request-Identity */ size_t eap_req_id_text_len; @@ -921,8 +924,6 @@ struct hostapd_config { SHORT_PREAMBLE = 1 } preamble; - int *supported_rates; - int *basic_rates; unsigned int beacon_rate; enum beacon_rate_type rate_type; diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 22e672c8d..63521d543 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -1361,7 +1361,7 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd, params->proberesp_len = resp_len; params->dtim_period = hapd->conf->dtim_period; params->beacon_int = hapd->iconf->beacon_int; - params->basic_rates = hapd->iface->basic_rates; + params->basic_rates = hapd->basic_rates; params->beacon_rate = hapd->iconf->beacon_rate; params->rate_type = hapd->iconf->rate_type; params->ssid = hapd->conf->ssid.ssid; diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c index ef53a8254..bebb75784 100644 --- a/src/ap/ctrl_iface_ap.c +++ b/src/ap/ctrl_iface_ap.c @@ -812,16 +812,16 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf, mode->mcs_set); } - if (iface->current_rates && iface->num_rates) { + if (hapd->current_rates && hapd->num_rates) { ret = os_snprintf(buf + len, buflen - len, "supported_rates="); if (os_snprintf_error(buflen - len, ret)) return len; len += ret; - for (j = 0; j < iface->num_rates; j++) { + for (j = 0; j < hapd->num_rates; j++) { ret = os_snprintf(buf + len, buflen - len, "%s%02x", j > 0 ? " " : "", - iface->current_rates[j].rate / 5); + hapd->current_rates[j].rate / 5); if (os_snprintf_error(buflen - len, ret)) return len; len += ret; diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index f9af038be..793666451 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -360,6 +360,10 @@ static void hostapd_free_hapd_data(struct hostapd_data *hapd) hapd->probereq_cb = NULL; hapd->num_probereq_cb = 0; + os_free(hapd->current_rates); + hapd->current_rates = NULL; + os_free(hapd->basic_rates); + hapd->basic_rates = NULL; #ifdef CONFIG_P2P wpabuf_free(hapd->p2p_beacon_ie); hapd->p2p_beacon_ie = NULL; @@ -503,10 +507,6 @@ static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface) hostapd_free_hw_features(iface->hw_features, iface->num_hw_features); iface->hw_features = NULL; iface->current_mode = NULL; - os_free(iface->current_rates); - iface->current_rates = NULL; - os_free(iface->basic_rates); - iface->basic_rates = NULL; ap_list_deinit(iface); sta_track_deinit(iface); airtime_policy_update_deinit(iface); @@ -1085,6 +1085,85 @@ static int db_table_create_radius_attributes(sqlite3 *db) #endif /* CONFIG_NO_RADIUS */ +static int hostapd_prepare_rates(struct hostapd_data *hapd, + struct hostapd_hw_modes *mode) +{ + struct hostapd_bss_config *conf = hapd->conf; + int i, num_basic_rates = 0; + int basic_rates_a[] = { 60, 120, 240, -1 }; + int basic_rates_b[] = { 10, 20, -1 }; + int basic_rates_g[] = { 10, 20, 55, 110, -1 }; + int *basic_rates; + + if (conf->basic_rates) + basic_rates = conf->basic_rates; + else switch (mode->mode) { + case HOSTAPD_MODE_IEEE80211A: + basic_rates = basic_rates_a; + break; + case HOSTAPD_MODE_IEEE80211B: + basic_rates = basic_rates_b; + break; + case HOSTAPD_MODE_IEEE80211G: + basic_rates = basic_rates_g; + break; + case HOSTAPD_MODE_IEEE80211AD: + return 0; /* No basic rates for 11ad */ + default: + return -1; + } + + i = 0; + while (basic_rates[i] >= 0) + i++; + if (i) + i++; /* -1 termination */ + os_free(hapd->basic_rates); + hapd->basic_rates = os_malloc(i * sizeof(int)); + if (hapd->basic_rates) + os_memcpy(hapd->basic_rates, basic_rates, i * sizeof(int)); + + os_free(hapd->current_rates); + hapd->num_rates = 0; + + hapd->current_rates = + os_calloc(mode->num_rates, sizeof(struct hostapd_rate_data)); + if (!hapd->current_rates) { + wpa_printf(MSG_ERROR, "Failed to allocate memory for rate " + "table."); + return -1; + } + + for (i = 0; i < mode->num_rates; i++) { + struct hostapd_rate_data *rate; + + if (conf->supported_rates && + !hostapd_rate_found(conf->supported_rates, + mode->rates[i])) + continue; + + rate = &hapd->current_rates[hapd->num_rates]; + rate->rate = mode->rates[i]; + if (hostapd_rate_found(basic_rates, rate->rate)) { + rate->flags |= HOSTAPD_RATE_BASIC; + num_basic_rates++; + } + wpa_printf(MSG_DEBUG, "RATE[%d] rate=%d flags=0x%x", + hapd->num_rates, rate->rate, rate->flags); + hapd->num_rates++; + } + + if ((hapd->num_rates == 0 || num_basic_rates == 0) && + (!hapd->iconf->ieee80211n || !hapd->iconf->require_ht)) { + wpa_printf(MSG_ERROR, "No rates remaining in supported/basic " + "rate sets (%d,%d).", + hapd->num_rates, num_basic_rates); + return -1; + } + + return 0; +} + /** * hostapd_setup_bss - Per-BSS setup (initialization) @@ -1109,6 +1188,17 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first) wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)", __func__, hapd, conf->iface, first); + if (hapd->iface->current_mode) { + if (hostapd_prepare_rates(hapd, hapd->iface->current_mode)) { + wpa_printf(MSG_ERROR, "Failed to prepare rates " + "table."); + hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, + HOSTAPD_LEVEL_WARNING, + "Failed to prepare rates table."); + return -1; + } + } + #ifdef EAP_SERVER_TNC if (conf->tnc && tncs_global_init() < 0) { wpa_printf(MSG_ERROR, "Failed to initialize TNCS"); @@ -2037,17 +2127,6 @@ static int hostapd_setup_interface_complete_sync(struct hostapd_iface *iface, } } - if (iface->current_mode) { - if (hostapd_prepare_rates(iface, iface->current_mode)) { - wpa_printf(MSG_ERROR, "Failed to prepare rates " - "table."); - hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, - HOSTAPD_LEVEL_WARNING, - "Failed to prepare rates table."); - goto fail; - } - } - if (hapd->iconf->rts_threshold >= -1 && hostapd_set_rts(hapd, hapd->iconf->rts_threshold) && hapd->iconf->rts_threshold >= -1) { diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 609c84b22..b62256487 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -184,6 +184,10 @@ struct hostapd_data { void *msg_ctx; /* ctx for wpa_msg() calls */ void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */ + int num_rates; + struct hostapd_rate_data *current_rates; + int *basic_rates; + struct radius_client_data *radius; u64 acct_session_id; struct radius_das_data *radius_das; @@ -507,11 +511,6 @@ struct hostapd_iface { struct hostapd_hw_modes *hw_features; int num_hw_features; struct hostapd_hw_modes *current_mode; - /* Rates that are currently used (i.e., filtered copy of - * current_mode->channels */ - int num_rates; - struct hostapd_rate_data *current_rates; - int *basic_rates; int freq; u16 hw_flags; diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index f6e69030d..9992a0478 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -145,85 +145,6 @@ int hostapd_get_hw_features(struct hostapd_iface *iface) } -int hostapd_prepare_rates(struct hostapd_iface *iface, - struct hostapd_hw_modes *mode) -{ - int i, num_basic_rates = 0; - int basic_rates_a[] = { 60, 120, 240, -1 }; - int basic_rates_b[] = { 10, 20, -1 }; - int basic_rates_g[] = { 10, 20, 55, 110, -1 }; - int *basic_rates; - - if (iface->conf->basic_rates) - basic_rates = iface->conf->basic_rates; - else switch (mode->mode) { - case HOSTAPD_MODE_IEEE80211A: - basic_rates = basic_rates_a; - break; - case HOSTAPD_MODE_IEEE80211B: - basic_rates = basic_rates_b; - break; - case HOSTAPD_MODE_IEEE80211G: - basic_rates = basic_rates_g; - break; - case HOSTAPD_MODE_IEEE80211AD: - return 0; /* No basic rates for 11ad */ - default: - return -1; - } - - i = 0; - while (basic_rates[i] >= 0) - i++; - if (i) - i++; /* -1 termination */ - os_free(iface->basic_rates); - iface->basic_rates = os_malloc(i * sizeof(int)); - if (iface->basic_rates) - os_memcpy(iface->basic_rates, basic_rates, i * sizeof(int)); - - os_free(iface->current_rates); - iface->num_rates = 0; - - iface->current_rates = - os_calloc(mode->num_rates, sizeof(struct hostapd_rate_data)); - if (!iface->current_rates) { - wpa_printf(MSG_ERROR, "Failed to allocate memory for rate " - "table."); - return -1; - } - - for (i = 0; i < mode->num_rates; i++) { - struct hostapd_rate_data *rate; - - if (iface->conf->supported_rates && - !hostapd_rate_found(iface->conf->supported_rates, - mode->rates[i])) - continue; - - rate = &iface->current_rates[iface->num_rates]; - rate->rate = mode->rates[i]; - if (hostapd_rate_found(basic_rates, rate->rate)) { - rate->flags |= HOSTAPD_RATE_BASIC; - num_basic_rates++; - } - wpa_printf(MSG_DEBUG, "RATE[%d] rate=%d flags=0x%x", - iface->num_rates, rate->rate, rate->flags); - iface->num_rates++; - } - - if ((iface->num_rates == 0 || num_basic_rates == 0) && - (!iface->conf->ieee80211n || !iface->conf->require_ht)) { - wpa_printf(MSG_ERROR, "No rates remaining in supported/basic " - "rate sets (%d,%d).", - iface->num_rates, num_basic_rates); - return -1; - } - - return 0; -} - - static int ieee80211n_allowed_ht40_channel_pair(struct hostapd_iface *iface) { int pri_freq, sec_freq; diff --git a/src/ap/hw_features.h b/src/ap/hw_features.h index dd24f95b2..fda9a242f 100644 --- a/src/ap/hw_features.h +++ b/src/ap/hw_features.h @@ -22,8 +22,6 @@ int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan); int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq); int hostapd_check_ht_capab(struct hostapd_iface *iface); int hostapd_check_edmg_capab(struct hostapd_iface *iface); -int hostapd_prepare_rates(struct hostapd_iface *iface, - struct hostapd_hw_modes *mode); void hostapd_stop_setup_timers(struct hostapd_iface *iface); int hostapd_hw_skip_mode(struct hostapd_iface *iface, struct hostapd_hw_modes *mode); @@ -69,12 +67,6 @@ static inline int hostapd_check_edmg_capab(struct hostapd_iface *iface) return 0; } -static inline int hostapd_prepare_rates(struct hostapd_iface *iface, - struct hostapd_hw_modes *mode) -{ - return 0; -} - static inline void hostapd_stop_setup_timers(struct hostapd_iface *iface) { } diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index f1f37027b..e1c32cc68 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -90,11 +90,11 @@ u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid) int i, num, count; int h2e_required; - if (hapd->iface->current_rates == NULL) + if (hapd->current_rates == NULL) return eid; *pos++ = WLAN_EID_SUPP_RATES; - num = hapd->iface->num_rates; + num = hapd->num_rates; if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) num++; if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) @@ -112,11 +112,11 @@ u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid) } *pos++ = num; - for (i = 0, count = 0; i < hapd->iface->num_rates && count < num; + for (i = 0, count = 0; i < hapd->num_rates && count < num; i++) { count++; - *pos = hapd->iface->current_rates[i].rate / 5; - if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC) + *pos = hapd->current_rates[i].rate / 5; + if (hapd->current_rates[i].flags & HOSTAPD_RATE_BASIC) *pos |= 0x80; pos++; } @@ -146,10 +146,10 @@ u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid) int i, num, count; int h2e_required; - if (hapd->iface->current_rates == NULL) + if (hapd->current_rates == NULL) return eid; - num = hapd->iface->num_rates; + num = hapd->num_rates; if (hapd->iconf->ieee80211n && hapd->iconf->require_ht) num++; if (hapd->iconf->ieee80211ac && hapd->iconf->require_vht) @@ -166,13 +166,13 @@ u8 * hostapd_eid_ext_supp_rates(struct hostapd_data *hapd, u8 *eid) *pos++ = WLAN_EID_EXT_SUPP_RATES; *pos++ = num; - for (i = 0, count = 0; i < hapd->iface->num_rates && count < num + 8; + for (i = 0, count = 0; i < hapd->num_rates && count < num + 8; i++) { count++; if (count <= 8) continue; /* already in SuppRates IE */ - *pos = hapd->iface->current_rates[i].rate / 5; - if (hapd->iface->current_rates[i].flags & HOSTAPD_RATE_BASIC) + *pos = hapd->current_rates[i].rate / 5; + if (hapd->current_rates[i].flags & HOSTAPD_RATE_BASIC) *pos |= 0x80; pos++; } diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index 67b5e9885..fd6392aca 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -699,11 +699,11 @@ struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr) } for (i = 0; i < WLAN_SUPP_RATES_MAX; i++) { - if (!hapd->iface->basic_rates) + if (!hapd->basic_rates) break; - if (hapd->iface->basic_rates[i] < 0) + if (hapd->basic_rates[i] < 0) break; - sta->supported_rates[i] = hapd->iface->basic_rates[i] / 5; + sta->supported_rates[i] = hapd->basic_rates[i] / 5; } sta->supported_rates_len = i; diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 624168205..65c6d96a6 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -320,7 +320,7 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s, list[2] = 240; list[3] = -1; } - conf->basic_rates = list; + bss->basic_rates = list; list = os_malloc(9 * sizeof(int)); if (list) { @@ -334,7 +334,7 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s, list[7] = 540; list[8] = -1; } - conf->supported_rates = list; + bss->supported_rates = list; } #ifdef CONFIG_IEEE80211AX diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c index c085466b1..acdce610c 100644 --- a/wpa_supplicant/mesh.c +++ b/wpa_supplicant/mesh.c @@ -224,7 +224,7 @@ static int wpas_mesh_complete(struct wpa_supplicant *wpa_s) params->ies = ifmsh->mconf->rsn_ie; params->ie_len = ifmsh->mconf->rsn_ie_len; - params->basic_rates = ifmsh->basic_rates; + params->basic_rates = ifmsh->bss[0]->basic_rates; params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE; params->conf.ht_opmode = ifmsh->bss[0]->iface->ht_op_mode; @@ -367,9 +367,9 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s, * advertised in beacons match the one in peering frames, sigh. */ if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G) { - conf->basic_rates = os_memdup(basic_rates_erp, + bss->conf->basic_rates = os_memdup(basic_rates_erp, sizeof(basic_rates_erp)); - if (!conf->basic_rates) + if (!bss->conf->basic_rates) goto out_free; } } else { @@ -379,12 +379,12 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s, break; rate_len++; } - conf->basic_rates = os_calloc(rate_len + 1, sizeof(int)); - if (conf->basic_rates == NULL) + bss->conf->basic_rates = os_calloc(rate_len + 1, sizeof(int)); + if (bss->conf->basic_rates == NULL) goto out_free; - os_memcpy(conf->basic_rates, ssid->mesh_basic_rates, + os_memcpy(bss->conf->basic_rates, ssid->mesh_basic_rates, rate_len * sizeof(int)); - conf->basic_rates[rate_len] = -1; + bss->conf->basic_rates[rate_len] = -1; } if (wpa_drv_init_mesh(wpa_s)) {