diff --git a/src/nl80211util.c b/src/nl80211util.c index 4a402e2f..0076aa51 100644 --- a/src/nl80211util.c +++ b/src/nl80211util.c @@ -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) diff --git a/src/nl80211util.h b/src/nl80211util.h index 6f7b9eab..d966e049 100644 --- a/src/nl80211util.h +++ b/src/nl80211util.h @@ -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],