diff mbox series

[2/2] iw: event: add set interface command

Message ID 20191210142245.13972-2-markus.theil@tu-ilmenau.de (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show
Series [1/2] iw: event: add new peer candidate command | expand

Commit Message

Markus Theil Dec. 10, 2019, 2:22 p.m. UTC
This patch adds support for CMD_SET_INTERFACE which is called
when switching to mesh or ap mode.

Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
 event.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
diff mbox series

Patch

diff --git a/event.c b/event.c
index f17e78e..0cedeb9 100644
--- a/event.c
+++ b/event.c
@@ -668,6 +668,46 @@  static void parse_new_peer_candidate(struct nlattr **attrs)
 	printf("\n");
 }
 
+static void parse_set_interface(struct nlattr **attrs)
+{
+	printf("set interface");
+
+	if (attrs[NL80211_ATTR_IFTYPE]) {
+		printf(" type ");
+		switch (nla_get_u32(attrs[NL80211_ATTR_IFTYPE])) {
+		case NL80211_IFTYPE_STATION:
+			printf("station");
+			break;
+		case NL80211_IFTYPE_AP:
+			printf("access point");
+			break;
+		case NL80211_IFTYPE_MESH_POINT:
+			printf("mesh point");
+			break;
+		case NL80211_IFTYPE_ADHOC:
+			printf("ad-hoc");
+			break;
+		case NL80211_IFTYPE_MONITOR:
+			printf("monitor");
+			break;
+		default:
+			printf("unknown");
+		}
+	}
+
+	if (attrs[NL80211_ATTR_MESH_ID]) {
+		printf(" meshid ");
+		print_ssid_escaped(nla_len(attrs[NL80211_ATTR_MESH_ID]),
+				   nla_data(attrs[NL80211_ATTR_MESH_ID]));
+	}
+
+	if (attrs[NL80211_ATTR_4ADDR]) {
+		printf(" use 4addr %i", nla_get_u8(attrs[NL80211_ATTR_4ADDR]));
+	}
+
+	printf("\n");
+}
+
 static int print_event(struct nl_msg *msg, void *arg)
 {
 	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@@ -1011,6 +1051,10 @@  static int print_event(struct nl_msg *msg, void *arg)
 		parse_new_peer_candidate(tb);
 		break;
 	}
+	case NL80211_CMD_SET_INTERFACE: {
+		parse_set_interface(tb);
+		break;
+	}
 	default:
 		printf("unknown event %d (%s)\n",
 		       gnlh->cmd, command_name(gnlh->cmd));