From patchwork Mon Nov 21 10:41:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 126731 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 C1787B6F7F for ; Mon, 21 Nov 2011 21:41:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2DA929C162; Mon, 21 Nov 2011 05:41:29 -0500 (EST) 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 4eQ1axVM7azK; Mon, 21 Nov 2011 05:41:28 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9AFB19C15A; Mon, 21 Nov 2011 05:41:23 -0500 (EST) 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 BB97E9C14D for ; Mon, 21 Nov 2011 05:41:21 -0500 (EST) 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 Ir090hxatsK4 for ; Mon, 21 Nov 2011 05:41:18 -0500 (EST) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id E09FD9C14C for ; Mon, 21 Nov 2011 05:41:17 -0500 (EST) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1RSRJM-0004DV-IY for hostap@lists.shmoo.com; Mon, 21 Nov 2011 11:41:16 +0100 Subject: [PATCH v4 05/15] driver_nl80211: store frequency in bss struct From: Johannes Berg To: hostap@lists.shmoo.com In-Reply-To: <20111119123950.893371399@sipsolutions.net> References: <20111119123910.783418920@sipsolutions.net> <20111119123950.893371399@sipsolutions.net> Date: Mon, 21 Nov 2011 11:41:13 +0100 Message-ID: <1321872073.3999.36.camel@jlt3.sipsolutions.net> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 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: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg Storing the frequency in the bss struct allows using it for frame commands in AP mode and not relying on the driver struct as much, which is good for hostapd mode. Signed-hostap: Johannes Berg --- v4: rebase onto Helmut's changes src/drivers/driver_nl80211.c | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 5b6061f..ea9dbed 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -189,6 +189,8 @@ struct i802_bss { unsigned int added_if_into_bridge:1; unsigned int added_bridge:1; + int freq; + struct nl80211_handles nl_preq; }; @@ -236,7 +238,6 @@ struct wpa_driver_nl80211_data { u64 send_action_cookie; unsigned int last_mgmt_freq; - unsigned int ap_oper_freq; struct wpa_driver_scan_filter *filter_ssids; size_t num_filter_ssids; @@ -4346,9 +4347,9 @@ static int wpa_driver_nl80211_send_mlme(void *priv, const u8 *data, } if (drv->device_ap_sme && is_ap_interface(drv->nlmode)) { - return nl80211_send_frame_cmd(bss, drv->ap_oper_freq, 0, - data, data_len, NULL, 0, noack, - 0); + return nl80211_send_frame_cmd(bss, bss->freq, 0, + data, data_len, NULL, + 0, noack, 0); } if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && @@ -4566,10 +4567,11 @@ static int wpa_driver_nl80211_set_ap(void *priv, } -static int wpa_driver_nl80211_set_freq(struct wpa_driver_nl80211_data *drv, +static int wpa_driver_nl80211_set_freq(struct i802_bss *bss, int freq, int ht_enabled, int sec_channel_offset) { + struct wpa_driver_nl80211_data *drv = bss->drv; struct nl_msg *msg; int ret; @@ -4602,8 +4604,10 @@ static int wpa_driver_nl80211_set_freq(struct wpa_driver_nl80211_data *drv, } ret = send_and_recv_msgs(drv, msg, NULL, NULL); - if (ret == 0) + if (ret == 0) { + bss->freq = freq; return 0; + } wpa_printf(MSG_DEBUG, "nl80211: Failed to set channel (freq=%d): " "%d (%s)", freq, ret, strerror(-ret)); nla_put_failure: @@ -5449,13 +5453,11 @@ static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv, nlmode = NL80211_IFTYPE_AP; if (wpa_driver_nl80211_set_mode(&drv->first_bss, nlmode) || - wpa_driver_nl80211_set_freq(drv, params->freq, 0, 0)) { + wpa_driver_nl80211_set_freq(&drv->first_bss, params->freq, 0, 0)) { nl80211_remove_monitor_interface(drv); return -1; } - drv->ap_oper_freq = params->freq; - return 0; } @@ -6082,8 +6084,7 @@ static int wpa_driver_nl80211_set_supp_port(void *priv, int authorized) static int i802_set_freq(void *priv, struct hostapd_freq_params *freq) { struct i802_bss *bss = priv; - struct wpa_driver_nl80211_data *drv = bss->drv; - return wpa_driver_nl80211_set_freq(drv, freq->freq, freq->ht_enabled, + return wpa_driver_nl80211_set_freq(bss, freq->freq, freq->ht_enabled, freq->sec_channel_offset); }