commit c93966d5a18d6222d26c276f4b4cfb7626b6ddc6
parent c54567491888cc61c10d79ac071debe8a90d91ec
Author: Denis Kenzior <denkenz@gmail.com>
Date: Fri, 3 Sep 2021 16:26:46 -0500
ie: Add parse utility for network cost vendor IE
Diffstat:
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/ie.c b/src/ie.c
@@ -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;
+}
diff --git a/src/ie.h b/src/ie.h
@@ -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);