diff mbox

iw: Print beacon-loss-event string.

Message ID 1359610289-4578-1-git-send-email-greearb@candelatech.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Ben Greear Jan. 31, 2013, 5:31 a.m. UTC
From: Ben Greear <greearb@candelatech.com>

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@candelatech.com>
---
:100644 100644 6f7027f... cb80bf8... M	event.c
 event.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

Comments

Johannes Berg Jan. 31, 2013, 3:40 p.m. UTC | #1
On Wed, 2013-01-30 at 21:31 -0800, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> 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.

Applied.

johannes

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

Patch

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;