[LEDE-DEV] [PATCH iwinfo] nl80211: request split information about frequencies

Rafał Miłecki zajec5 at gmail.com
Tue Aug 15 03:11:22 PDT 2017


From: Rafał Miłecki <rafal at milecki.pl>

This allows kernel send more details including all the
NL80211_FREQUENCY_ATTR_NO_* flags.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 iwinfo_nl80211.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 718e111..77e0423 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -425,6 +425,30 @@ static struct nlattr ** nl80211_parse(struct nl_msg *msg)
 	return attr;
 }
 
+static int nl80211_get_protocol_features_cb(struct nl_msg *msg, void *arg)
+{
+	uint32_t *features = arg;
+	struct nlattr **attr = nl80211_parse(msg);
+
+	if (attr[NL80211_ATTR_PROTOCOL_FEATURES])
+		*features = nla_get_u32(attr[NL80211_ATTR_PROTOCOL_FEATURES]);
+
+	return NL_SKIP;
+}
+
+static int nl80211_get_protocol_features(const char *ifname)
+{
+	struct nl80211_msg_conveyor *req;
+	uint32_t features = 0;
+
+	req = nl80211_msg(ifname, NL80211_CMD_GET_PROTOCOL_FEATURES, 0);
+	if (req) {
+		nl80211_send(req, nl80211_get_protocol_features_cb, &features);
+		nl80211_free(req);
+	}
+
+	return features;
+}
 
 static int nl80211_subscribe_cb(struct nl_msg *msg, void *arg)
 {
@@ -2426,15 +2450,25 @@ static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
 
 static int nl80211_get_freqlist(const char *ifname, char *buf, int *len)
 {
+	struct nl80211_msg_conveyor *cv;
 	struct nl80211_array_buf arr = { .buf = buf, .count = 0 };
+	uint32_t features = nl80211_get_protocol_features(ifname);
+	int flags;
 
-	if (nl80211_request(ifname, NL80211_CMD_GET_WIPHY, 0,
-	                    nl80211_get_freqlist_cb, &arr))
+	flags = features & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP ? NLM_F_DUMP : 0;
+	cv = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, flags);
+	if (!cv)
+		goto out;
+
+	NLA_PUT_FLAG(cv->msg, NL80211_ATTR_SPLIT_WIPHY_DUMP);
+	if (nl80211_send(cv, nl80211_get_freqlist_cb, &arr))
 		goto out;
 
 	*len = arr.count * sizeof(struct iwinfo_freqlist_entry);
 	return 0;
 
+nla_put_failure:
+	nl80211_free(cv);
 out:
 	*len = 0;
 	return -1;
-- 
2.11.0




More information about the Lede-dev mailing list