BSS: Add wpa_bss_get_vendor_ie_multi_beacon()
[mech_eap.git] / wpa_supplicant / bss.c
index 434fb08..503aaa9 100644 (file)
@@ -721,6 +721,38 @@ struct wpabuf * wpa_bss_get_vendor_ie_multi(const struct wpa_bss *bss,
 }
 
 
+struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
+                                                  u32 vendor_type)
+{
+       struct wpabuf *buf;
+       const u8 *end, *pos;
+
+       buf = wpabuf_alloc(bss->beacon_ie_len);
+       if (buf == NULL)
+               return NULL;
+
+       pos = (const u8 *) (bss + 1);
+       pos += bss->ie_len;
+       end = pos + bss->beacon_ie_len;
+
+       while (pos + 1 < end) {
+               if (pos + 2 + pos[1] > end)
+                       break;
+               if (pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 &&
+                   vendor_type == WPA_GET_BE32(&pos[2]))
+                       wpabuf_put_data(buf, pos + 2 + 4, pos[1] - 4);
+               pos += 2 + pos[1];
+       }
+
+       if (wpabuf_len(buf) == 0) {
+               wpabuf_free(buf);
+               buf = NULL;
+       }
+
+       return buf;
+}
+
+
 int wpa_bss_get_max_rate(const struct wpa_bss *bss)
 {
        int rate = 0;