From fd4ab5d3dfa2cb36c5930b61469e1df4724fc486 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Fri, 19 May 2017 03:39:31 +0200 Subject: [PATCH] wiphy: Add wiphy_get_ext_feature Save the extended features reported by the wiphy in the NEW_WIPHY event or GET_WIPHY dump and allow netdev to query it with wiphy_get_ext_feature() --- src/wiphy.c | 14 ++++++++++++++ src/wiphy.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index 650d6a16..abff4376 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -43,6 +43,7 @@ #include "src/rfkill.h" #include "src/wiphy.h" #include "src/storage.h" +#include "src/util.h" static struct l_genl_family *nl80211 = NULL; static struct l_hwdb *hwdb; @@ -53,6 +54,7 @@ struct wiphy { uint32_t id; char name[20]; uint32_t feature_flags; + uint8_t ext_features[2]; bool support_scheduled_scan:1; bool support_rekey_offload:1; uint16_t supported_ciphers; @@ -179,6 +181,12 @@ bool wiphy_can_connect(struct wiphy *wiphy, struct scan_bss *bss) return true; } +bool wiphy_get_ext_feature(struct wiphy *wiphy, unsigned int idx) +{ + return idx < sizeof(wiphy->ext_features) * 8 && + util_is_bit_set(wiphy->ext_features[idx >> 3], idx & 7); +} + static void wiphy_print_basic_info(struct wiphy *wiphy) { uint32_t bands; @@ -339,6 +347,12 @@ static void wiphy_parse_attributes(struct wiphy *wiphy, else wiphy->feature_flags = *((uint32_t *) data); + break; + case NL80211_ATTR_EXT_FEATURES: + if (len > sizeof(wiphy->ext_features)) + len = sizeof(wiphy->ext_features); + + memcpy(wiphy->ext_features, data, len); break; case NL80211_ATTR_SUPPORTED_COMMANDS: if (l_genl_attr_recurse(attr, &nested)) diff --git a/src/wiphy.h b/src/wiphy.h index c4a2cc30..762f8279 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -34,6 +34,7 @@ struct wiphy *wiphy_find(int wiphy_id); const char *wiphy_get_path(struct wiphy *wiphy); uint32_t wiphy_get_supported_bands(struct wiphy *wiphy); bool wiphy_can_connect(struct wiphy *wiphy, struct scan_bss *bss); +bool wiphy_get_ext_feature(struct wiphy *wiphy, unsigned int idx); bool wiphy_init(struct l_genl_family *in, const char *whitelist, const char *blacklist);