diff mbox

iw: add survey busy ratios

Message ID 20101006033039.17342.55809.stgit@tt-desk (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Bruno Randolf Oct. 6, 2010, 3:30 a.m. UTC
None
diff mbox

Patch

diff --git a/survey.c b/survey.c
index f9f2508..3257e9f 100644
--- a/survey.c
+++ b/survey.c
@@ -23,6 +23,9 @@  static int print_survey_handler(struct nl_msg *msg, void *arg)
 	static struct nla_policy survey_policy[NL80211_SURVEY_INFO_MAX + 1] = {
 		[NL80211_SURVEY_INFO_FREQUENCY] = { .type = NLA_U32 },
 		[NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
+		[NL80211_SURVEY_INFO_BUSY] = { .type = NLA_U8 },
+		[NL80211_SURVEY_INFO_BUSY_TX] = { .type = NLA_U8 },
+		[NL80211_SURVEY_INFO_BUSY_RX] = { .type = NLA_U8 },
 	};
 
 	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
@@ -49,6 +52,18 @@  static int print_survey_handler(struct nl_msg *msg, void *arg)
 	if (sinfo[NL80211_SURVEY_INFO_NOISE])
 		printf("\tnoise:\t\t%d dBm\n",
 			(int8_t)nla_get_u8(sinfo[NL80211_SURVEY_INFO_NOISE]));
+	if (sinfo[NL80211_SURVEY_INFO_BUSY])
+		printf("\tbusy:\t\t%d%%\n",
+			((int8_t)nla_get_u8(sinfo[NL80211_SURVEY_INFO_BUSY])
+			* 100) / 255);
+	if (sinfo[NL80211_SURVEY_INFO_BUSY_RX])
+		printf("\tbusy rx:\t%d%%\n",
+			((int8_t)nla_get_u8(sinfo[NL80211_SURVEY_INFO_BUSY_RX])
+			* 100) / 255);
+	if (sinfo[NL80211_SURVEY_INFO_BUSY_TX])
+		printf("\tbusy tx:\t%d%%\n",
+			((int8_t)nla_get_u8(sinfo[NL80211_SURVEY_INFO_BUSY_TX])
+			* 100) / 255);
 	return NL_SKIP;
 }