eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit b4983fdcae4de1e5b085cd0dfbb4928ee7faef4a
parent 16a05316b255eb1c34fc69c4bbbf25a26ef932c8
Author: James Prestwood <prestwoj@gmail.com>
Date:   Tue, 18 Jun 2024 09:58:48 -0700

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.

Diffstat:
Msrc/nl80211util.c | 37+++++++++++++++++++++++++++++++++++++
Msrc/nl80211util.h | 1+
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git 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 @@ -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],