From 0b0fd5639f93d0c5a5ba7d242697bbcb27ee42a9 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 31 May 2016 16:17:00 -0500 Subject: [PATCH] wiphy: Parse NEW_WIPHY and DEL_WIPHY events --- src/wiphy.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/wiphy.c b/src/wiphy.c index c6cca6cf..5e1c219b 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -1742,7 +1742,40 @@ static void wiphy_config_notify(struct l_genl_msg *msg, void *user_data) if (!l_genl_attr_init(&attr, msg)) return; - while (l_genl_attr_next(&attr, &type, &len, &data)) { + switch (cmd) { + case NL80211_CMD_NEW_WIPHY: + case NL80211_CMD_DEL_WIPHY: + { + const uint32_t *wiphy_id = NULL; + const char *wiphy_name = NULL; + + while (l_genl_attr_next(&attr, &type, &len, &data)) { + switch (type) { + case NL80211_ATTR_WIPHY: + if (len != sizeof(uint32_t)) { + l_warn("Invalid wiphy attribute"); + return; + } + + wiphy_id = data; + break; + + case NL80211_ATTR_WIPHY_NAME: + wiphy_name = data; + break; + } + } + + if (!wiphy_id) + return; + + if (cmd == NL80211_CMD_NEW_WIPHY) + l_info("New Wiphy %s[%d] added", wiphy_name, *wiphy_id); + else + l_info("Wiphy %s[%d] removed", wiphy_name, *wiphy_id); + + break; + } } }