3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-26 01:02:35 +01:00

nl80211util: add nl80211_parse_nested

Add a nested attribute parser. For the first supported attribute
add NL80211_ATTR_SURVEY_INFO.

This allows parsing of nested attributes in the same convenient
way as nl80211_parse_attrs but allows for support of any level of
nested attributes provided that a handler is added for each.
This commit is contained in:
James Prestwood 2024-06-18 09:58:48 -07:00 committed by Denis Kenzior
parent 16a05316b2
commit b4983fdcae
2 changed files with 38 additions and 0 deletions

View File

@ -193,6 +193,20 @@ static attr_handler handler_for_nl80211(int type)
return NULL;
}
static attr_handler handler_for_survey_info(int type)
{
switch (type) {
case NL80211_SURVEY_INFO_NOISE:
return extract_u8;
case NL80211_SURVEY_INFO_FREQUENCY:
return extract_uint32;
default:
break;
}
return NULL;
}
struct attr_entry {
uint16_t type;
void *data;
@ -297,6 +311,29 @@ int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...)
return ret;
}
int nl80211_parse_nested(struct l_genl_attr *attr, int type, int tag, ...)
{
handler_for_type handler;
va_list args;
int ret;
switch (type) {
case NL80211_ATTR_SURVEY_INFO:
handler = handler_for_survey_info;
break;
default:
return -ENOTSUP;
}
va_start(args, tag);
ret = parse_attrs(attr, handler, tag, args);
va_end(args);
return ret;
}
struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex,
const uint8_t addr[static 6],
uint16_t reason_code)

View File

@ -28,6 +28,7 @@ struct band_freq_attrs;
struct handshake_state;
int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...);
int nl80211_parse_nested(struct l_genl_attr *attr, int type, int tag, ...);
struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex,
const uint8_t addr[static 6],