[PATCH V3] wpa_supplicant: Add AVG_RSSI report in signal_poll

Ilan Peer ilan.peer
Tue Jun 18 02:05:35 PDT 2013


From: Andrei Otcheretianski <andrei.otcheretianski at intel.com>

Add AVG_RSSI report to the signal_poll command if it is reported by
the kernel.

Signed-hostap: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
Signed-hostap: Ilan Peer <ilan.peer at intel.com>
---
 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;
 }
 
 
-- 
1.7.10.4




More information about the Hostap mailing list