From patchwork Tue Jun 18 09:05:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilan Peer X-Patchwork-Id: 252216 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 4DF262C00A0 for ; Tue, 18 Jun 2013 20:04:56 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 5209D9C136; Tue, 18 Jun 2013 06:04:54 -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 UU2moYGVmhIz; Tue, 18 Jun 2013 06:04:54 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7597F9C0E0; Tue, 18 Jun 2013 06:04:49 -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 5DD5E9C0DC for ; Tue, 18 Jun 2013 06:04: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 G0eg8ujTyW5B for ; Tue, 18 Jun 2013 06:04:42 -0400 (EDT) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 391F69C121 for ; Tue, 18 Jun 2013 06:04:41 -0400 (EDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 18 Jun 2013 03:04:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,888,1363158000"; d="scan'208";a="355402266" Received: from ipeer-e6430-1.jer.intel.com ([10.12.217.147]) by orsmga002.jf.intel.com with ESMTP; 18 Jun 2013 03:04:13 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [PATCH V3] wpa_supplicant: Add AVG_RSSI report in signal_poll Date: Tue, 18 Jun 2013 12:05:35 +0300 Message-Id: <1371546335-3317-2-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371546335-3317-1-git-send-email-ilan.peer@intel.com> References: <1371546335-3317-1-git-send-email-ilan.peer@intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 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: Andrei Otcheretianski Add AVG_RSSI report to the signal_poll command if it is reported by the kernel. Signed-hostap: Andrei Otcheretianski Signed-hostap: Ilan Peer --- src/drivers/driver.h | 1 + src/drivers/driver_nl80211.c | 8 ++++++++ wpa_supplicant/ctrl_iface.c | 26 +++++++++++++++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 07cc1d2..e18ee65 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1108,6 +1108,7 @@ struct wpa_signal_info { u32 frequency; int above_threshold; int current_signal; + int avg_signal; int current_noise; int current_txrate; enum chan_width chanwidth; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 5484d87..ac3c6bc 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -1765,6 +1765,7 @@ static int get_link_signal(struct nl_msg *msg, void *arg) struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1]; static struct nla_policy policy[NL80211_STA_INFO_MAX + 1] = { [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 }, + [NL80211_STA_INFO_SIGNAL_AVG] = { .type = NLA_U8 }, }; struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1]; static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = { @@ -1787,6 +1788,13 @@ static int get_link_signal(struct nl_msg *msg, void *arg) sig_change->current_signal = (s8) nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]); + + if (sinfo[NL80211_STA_INFO_SIGNAL_AVG]) + sig_change->avg_signal = + (s8) nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]); + else + sig_change->avg_signal = 0; + if (sinfo[NL80211_STA_INFO_TX_BITRATE]) { if (nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX, sinfo[NL80211_STA_INFO_TX_BITRATE], diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 7b26493..20efaf4 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -5024,21 +5024,37 @@ static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf, { struct wpa_signal_info si; int ret; - + char *pos, *end; ret = wpa_drv_signal_poll(wpa_s, &si); if (ret) return -1; - ret = os_snprintf(buf, buflen, "RSSI=%d\nLINKSPEED=%d\n" + pos = buf; + end = buf + buflen; + + ret = os_snprintf(pos, end - pos, "RSSI=%d\n" + "LINKSPEED=%d\n" "NOISE=%d\nFREQUENCY=%u\nWIDTH=%s\n" "CENTER_FRQ1=%d\nCENTER_FRQ2=%d\n", - si.current_signal, si.current_txrate / 1000, + si.current_signal, + si.current_txrate / 1000, si.current_noise, si.frequency, channel_width_name(si.chanwidth), si.center_frq1, si.center_frq2); - if (ret < 0 || (unsigned int) ret > buflen) + if (ret < 0 || ret >= end - pos) return -1; - return ret; + pos += ret; + + /* Append AVG_RSSI if present */ + if (si.avg_signal) { + ret = os_snprintf(pos, end - pos, + "AVG_RSSI=%d\n", si.avg_signal); + if (ret < 0 || ret >= end - pos) + return -1; + pos += ret; + } + + return pos - buf; }