diff mbox

iw: print human readable radar events

Message ID 1422610964-23252-1-git-send-email-helmut.schaa@googlemail.com (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show

Commit Message

Helmut Schaa Jan. 30, 2015, 9:42 a.m. UTC
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
---
 event.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Joe Perches Jan. 30, 2015, 10:36 a.m. UTC | #1
On Fri, 2015-01-30 at 10:42 +0100, Helmut Schaa wrote:
> diff --git a/event.c b/event.c
[]
> @@ -565,6 +565,31 @@ static int print_event(struct nl_msg *msg, void *arg)
>  				   nla_data(tb[NL80211_ATTR_VENDOR_DATA]),
>  				   nla_len(tb[NL80211_ATTR_VENDOR_DATA]));
>  		break;
> +	case NL80211_CMD_RADAR_DETECT:
> +		printf("radar event ");
> +		if (tb[NL80211_ATTR_RADAR_EVENT]) {
> +			switch (nla_get_u32(tb[NL80211_ATTR_RADAR_EVENT])) {
> +				case NL80211_RADAR_DETECTED:
> +					printf("(radar detected)");
> +					break;
> +				case NL80211_RADAR_CAC_FINISHED:
> +					printf("(cac finished)");
> +					break;
> +				case NL80211_RADAR_CAC_ABORTED:
> +					printf("(cac aborted)");
> +					break;
> +				case NL80211_RADAR_NOP_FINISHED:
> +					printf("(nop finished)");
> +					break;
> +				default:
> +					printf("(unknown)");
> +					break;
> +			};
> +		} else {
> +			printf("(unknown)");
> +		}
> +		printf("\n");
> +		break;

Might be better with a const char * use

	case NL80211_CMD_RADAR_DETECT: {
		const char *type = "unknown";

		if (tb[NL80211_ATTR_RADAR_EVENT]) {
			switch (nla_get_u32(tb[NL80211_ATTR_RADAR_EVENT])) {
			case NL80211_RADAR_DETECTED:
				type = "radar detected";
				break;
			case NL80211_RADAR_CAC_FINISHED:
				type = "cac finished";
				break;
			case NL80211_RADAR_CAC_ABORTED:
				type = "cac aborted";
				break;
			case NL80211_RADAR_NOP_FINISHED:
				type = "nop finished";
				break;
			}
		}
		printf("radar event: (%s)\n", type);
	}


--
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
Helmut Schaa Feb. 2, 2015, 10:01 a.m. UTC | #2
On Fri, Jan 30, 2015 at 11:36 AM, Joe Perches <joe@perches.com> wrote:
> Might be better with a const char * use

Yeah, could do that.
However, this is consistent with the rest of the code in iw, so should
be fine as is.

Thanks,
Helmut
--
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
Johannes Berg March 3, 2015, 8:37 a.m. UTC | #3
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 c175c66..71ab7f7 100644
--- a/event.c
+++ b/event.c
@@ -565,6 +565,31 @@  static int print_event(struct nl_msg *msg, void *arg)
 				   nla_data(tb[NL80211_ATTR_VENDOR_DATA]),
 				   nla_len(tb[NL80211_ATTR_VENDOR_DATA]));
 		break;
+	case NL80211_CMD_RADAR_DETECT:
+		printf("radar event ");
+		if (tb[NL80211_ATTR_RADAR_EVENT]) {
+			switch (nla_get_u32(tb[NL80211_ATTR_RADAR_EVENT])) {
+				case NL80211_RADAR_DETECTED:
+					printf("(radar detected)");
+					break;
+				case NL80211_RADAR_CAC_FINISHED:
+					printf("(cac finished)");
+					break;
+				case NL80211_RADAR_CAC_ABORTED:
+					printf("(cac aborted)");
+					break;
+				case NL80211_RADAR_NOP_FINISHED:
+					printf("(nop finished)");
+					break;
+				default:
+					printf("(unknown)");
+					break;
+			};
+		} else {
+			printf("(unknown)");
+		}
+		printf("\n");
+		break;
 	default:
 		printf("unknown event %d (%s)\n",
 		       gnlh->cmd, command_name(gnlh->cmd));