3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-28 21:19:24 +01:00

nl80211util: add nested attribute support

Adds support for nested attributes in nl80211_parse_attrs
This commit is contained in:
James Prestwood 2022-07-26 10:09:20 -07:00 committed by Denis Kenzior
parent f2961cd63a
commit d9a16fee56

View File

@ -128,6 +128,16 @@ static bool extract_iovec(const void *data, uint16_t len, void *o)
return true; 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) static attr_handler handler_for_type(enum nl80211_attrs type)
{ {
switch (type) { switch (type) {
@ -157,6 +167,8 @@ static attr_handler handler_for_type(enum nl80211_attrs type)
return extract_uint32; return extract_uint32;
case NL80211_ATTR_FRAME: case NL80211_ATTR_FRAME:
return extract_iovec; return extract_iovec;
case NL80211_ATTR_WIPHY_BANDS:
return extract_nested;
default: default:
break; break;
} }
@ -222,6 +234,10 @@ int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...)
goto done; 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)) { if (!entry->handler(data, len, entry->data)) {
ret = -EINVAL; ret = -EINVAL;
goto done; goto done;