Search Linux Wireless

[PATCH] iw: Print beacon-loss-event string.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ben Greear <greearb@xxxxxxxxxxxxxxx>

There are now three possible threshold events.  The old
code assumed only above/below RSSI, and printed out 'low'
for beacon-loss-event.

Fix that, and do so with a switch statement so the compiler
can warn if the enum is further expanded w/out updating this
code.

Shorten 'connection quality monitor' to CQM to keep total string
relatively short.

Signed-off-by: Ben Greear <greearb@xxxxxxxxxxxxxxx>
---
:100644 100644 6f7027f... cb80bf8... M	event.c
 event.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/event.c b/event.c
index 6f7027f..cb80bf8 100644
--- a/event.c
+++ b/event.c
@@ -110,7 +110,7 @@ static void parse_cqm_event(struct nlattr **attrs)
 	struct nlattr *cqm[NL80211_ATTR_CQM_MAX + 1];
 	struct nlattr *cqm_attr = attrs[NL80211_ATTR_CQM];
 
-	printf("connection quality monitor event: ");
+	printf("CQM event: ");
 
 	if (!cqm_attr ||
 	    nla_parse_nested(cqm, NL80211_ATTR_CQM_MAX, cqm_attr, cqm_policy)) {
@@ -120,11 +120,24 @@ static void parse_cqm_event(struct nlattr **attrs)
 
 	if (cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]) {
 		enum nl80211_cqm_rssi_threshold_event rssi_event;
+                bool found_one = false;
 		rssi_event = nla_get_u32(cqm[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT]);
-		if (rssi_event == NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH)
-			printf("RSSI went above threshold\n");
-		else
+		switch(rssi_event) {
+                case NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH:
+                        printf("RSSI went above threshold\n");
+                        found_one = true;
+                        break;
+                case NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW:
 			printf("RSSI went below threshold\n");
+                        found_one = true;
+                        break;
+                case NL80211_CQM_RSSI_BEACON_LOSS_EVENT:
+			printf("Beacon loss detected\n");
+                        found_one = true;
+                        break;
+                }/* switch */
+                if (!found_one)
+                        printf("Unknown event type: %i\n", rssi_event);
 	} else if (cqm[NL80211_ATTR_CQM_PKT_LOSS_EVENT] &&
 		   attrs[NL80211_ATTR_MAC]) {
 		uint32_t frames;
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux