diff mbox series

[10/10] nl80211util: add nested attribute support

Message ID 20220726170920.15929-10-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [01/10] manager: unregister nl80211 config watch | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood July 26, 2022, 5:09 p.m. UTC
Adds support for nested attributes in nl80211_parse_attrs
---
 src/nl80211util.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/src/nl80211util.c b/src/nl80211util.c
index 9cd538ec..9092b204 100644
--- a/src/nl80211util.c
+++ b/src/nl80211util.c
@@ -128,6 +128,16 @@  static bool extract_iovec(const void *data, uint16_t len, void *o)
 	return true;
 }
 
+static bool extract_nested(const void *data, uint16_t len, void *o)
+{
+	const struct l_genl_attr *outer = data;
+	struct l_genl_attr *nested = o;
+
+	l_genl_attr_recurse(outer, nested);
+
+	return true;
+}
+
 static attr_handler handler_for_type(enum nl80211_attrs type)
 {
 	switch (type) {
@@ -157,6 +167,8 @@  static attr_handler handler_for_type(enum nl80211_attrs type)
 		return extract_uint32;
 	case NL80211_ATTR_FRAME:
 		return extract_iovec;
+	case NL80211_ATTR_WIPHY_BANDS:
+		return extract_nested;
 	default:
 		break;
 	}
@@ -222,6 +234,10 @@  int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...)
 			goto done;
 		}
 
+		/* For nested attributes use the outer attribute as data */
+		if (entry->handler == extract_nested)
+			data = &attr;
+
 		if (!entry->handler(data, len, entry->data)) {
 			ret = -EINVAL;
 			goto done;