mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-05 19:49:23 +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:
parent
16a05316b2
commit
b4983fdcae
@ -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)
|
||||
|
@ -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],
|
||||
|
Loading…
Reference in New Issue
Block a user