3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-19 01:42:33 +01:00

ie: Add [extended] supported rates parser

This commit is contained in:
Denis Kenzior 2015-06-10 12:13:57 -05:00
parent eee6e7db29
commit 7cded805ce
2 changed files with 53 additions and 0 deletions

View File

@ -1168,3 +1168,51 @@ int ie_parse_bss_load_from_data(const uint8_t *data, uint8_t len,
return ie_parse_bss_load(&iter, out_sta_count,
out_channel_utilization, out_admission_capacity);
}
int ie_parse_supported_rates(struct ie_tlv_iter *iter,
struct l_uintset **set)
{
const uint8_t *rates;
unsigned int len;
unsigned int i;
len = ie_tlv_iter_get_length(iter);
if (ie_tlv_iter_get_tag(iter) == IE_TYPE_SUPPORTED_RATES &&
len != 8)
return -EINVAL;
rates = ie_tlv_iter_get_data(iter);
if (!*set)
*set = l_uintset_new(108);
for (i = 0; i < len; i++) {
if (rates[i] == 0xff)
continue;
l_uintset_put(*set, rates[i] & 0x7f);
}
return 0;
}
int ie_parse_supported_rates_from_data(const uint8_t *data, uint8_t len,
struct l_uintset **set)
{
struct ie_tlv_iter iter;
uint8_t tag;
ie_tlv_iter_init(&iter, data, len);
if (!ie_tlv_iter_next(&iter))
return -EMSGSIZE;
tag = ie_tlv_iter_get_tag(&iter);
if (tag != IE_TYPE_SUPPORTED_RATES &&
tag != IE_TYPE_EXTENDED_SUPPORTED_RATES)
return -EPROTOTYPE;
return ie_parse_supported_rates(&iter, set);
}

View File

@ -279,3 +279,8 @@ int ie_parse_bss_load_from_data(const uint8_t *data, uint8_t len,
uint16_t *out_sta_count,
uint8_t *out_channel_utilization,
uint16_t *out_admission_capacity);
int ie_parse_supported_rates(struct ie_tlv_iter *iter,
struct l_uintset **set);
int ie_parse_supported_rates_from_data(const uint8_t *data, uint8_t len,
struct l_uintset **set);