3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

ie: Add parse utility for network cost vendor IE

This commit is contained in:
Denis Kenzior 2021-09-03 16:26:46 -05:00
parent c545674918
commit c93966d5a1
2 changed files with 23 additions and 0 deletions

View File

@ -2472,3 +2472,23 @@ void ie_build_fils_ip_addr_response(
done:
*len = to - (len + 1);
}
/*
* Parse Network Cost IE according to:
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-nct/88f0cdf4-cdf2-4455-b849-4abf1e5c11ac
*/
int ie_parse_network_cost(const void *data, size_t len,
uint16_t *level, uint16_t *flags)
{
const uint8_t *ie = data;
if (len < 10 || ie[0] != IE_TYPE_VENDOR_SPECIFIC || ie[1] != 8)
return -ENOMSG;
if (memcmp(ie + 2, microsoft_oui, 3) || ie[5] != 0x11)
return -ENOMSG;
*level = l_get_le16(ie + 6);
*flags = l_get_le16(ie + 8);
return 0;
}

View File

@ -626,3 +626,6 @@ int ie_parse_fils_ip_addr_response(struct ie_tlv_iter *iter,
void ie_build_fils_ip_addr_response(
const struct ie_fils_ip_addr_response_info *info,
uint8_t *to);
int ie_parse_network_cost(const void *data, size_t len,
uint16_t *flags, uint16_t *level);