eiwd

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

commit 74761fcdd30d7f4efbf2545bae27e042a73fa83e
parent 8679b82db47163dfa7e99d697146171ee8a94ad8
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Fri, 28 May 2021 16:06:26 -0500

wiphy: Add wiphy_estimate_data_rate

The data rate estimation belongs in wiphy since it should take hardware
capabilities into account.  Right now the data rate calculation simply
assumes the hardware is as capable as the AP.  scan.c will be ported to
use this utility and the data rate estimation will be expanded to take
wiphy capabilities into account.

Diffstat:
Msrc/wiphy.c | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/wiphy.h | 5+++++
2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/wiphy.c b/src/wiphy.c @@ -687,6 +687,56 @@ void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out) out[1] = country[1]; } +int wiphy_estimate_data_rate(struct wiphy *wiphy, + const void *ies, uint16_t ies_len, + const struct scan_bss *bss, + uint64_t *out_data_rate) +{ + struct ie_tlv_iter iter; + const void *supported_rates = NULL; + const void *ext_supported_rates = NULL; + const void *vht_capabilities = NULL; + const void *ht_capabilities = NULL; + + ie_tlv_iter_init(&iter, ies, ies_len); + + while (ie_tlv_iter_next(&iter)) { + uint8_t tag = ie_tlv_iter_get_tag(&iter); + + switch (tag) { + case IE_TYPE_SUPPORTED_RATES: + if (iter.len > 8) + return -EBADMSG; + + supported_rates = iter.data - 2; + break; + case IE_TYPE_EXTENDED_SUPPORTED_RATES: + ext_supported_rates = iter.data - 2; + break; + case IE_TYPE_HT_CAPABILITIES: + if (iter.len != 26) + return -EBADMSG; + + ht_capabilities = iter.data - 2; + break; + case IE_TYPE_VHT_CAPABILITIES: + if (iter.len != 12) + return false; + + vht_capabilities = iter.data - 2; + break; + default: + break; + } + } + + return ie_parse_data_rates(supported_rates, ext_supported_rates, + ht_capabilities, + vht_capabilities, + bss->signal_strength / 100, + out_data_rate); +} + uint32_t wiphy_state_watch_add(struct wiphy *wiphy, wiphy_state_watch_func_t func, void *user_data, wiphy_destroy_func_t destroy) diff --git a/src/wiphy.h b/src/wiphy.h @@ -107,6 +107,11 @@ void wiphy_generate_random_address(struct wiphy *wiphy, uint8_t addr[static 6]); void wiphy_generate_address_from_ssid(struct wiphy *wiphy, const char *ssid, uint8_t addr[static 6]); +int wiphy_estimate_data_rate(struct wiphy *wiphy, + const void *ies, uint16_t ies_len, + const struct scan_bss *bss, + uint64_t *out_data_rate); + uint32_t wiphy_state_watch_add(struct wiphy *wiphy, wiphy_state_watch_func_t func, void *user_data, wiphy_destroy_func_t destroy);