From 99a6a63f2546ed0afb5c15c633e5304dad7118fa Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 28 Dec 2009 01:09:32 +0200 Subject: [PATCH] Add wpa_bss_get_max_rate() to match with old scan_res helpers --- wpa_supplicant/bss.c | 22 ++++++++++++++++++++++ wpa_supplicant/bss.h | 1 + 2 files changed, 23 insertions(+) diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 96ab955ac..3d2a13b5c 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -356,3 +356,25 @@ struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss, return buf; } + + +int wpa_bss_get_max_rate(const struct wpa_bss *bss) +{ + int rate = 0; + const u8 *ie; + int i; + + ie = wpa_bss_get_ie(bss, WLAN_EID_SUPP_RATES); + for (i = 0; ie && i < ie[1]; i++) { + if ((ie[i + 2] & 0x7f) > rate) + rate = ie[i + 2] & 0x7f; + } + + ie = wpa_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES); + for (i = 0; ie && i < ie[1]; i++) { + if ((ie[i + 2] & 0x7f) > rate) + rate = ie[i + 2] & 0x7f; + } + + return rate; +} diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h index e861e8a3e..8eaeb584f 100644 --- a/wpa_supplicant/bss.h +++ b/wpa_supplicant/bss.h @@ -79,5 +79,6 @@ const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie); const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type); struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss, u32 vendor_type); +int wpa_bss_get_max_rate(const struct wpa_bss *bss); #endif /* BSS_H */