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 */