]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
BSS: Add wpa_bss_get_vendor_ie_multi_beacon()
authorJouni Malinen <j@w1.fi>
Sun, 2 Sep 2012 16:54:42 +0000 (19:54 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 2 Sep 2012 16:54:42 +0000 (19:54 +0300)
This can be used to fetch vendor IEs from Beacon frames.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/bss.c
wpa_supplicant/bss.h

index 434fb08a75c4ffeb005ef83f4cd7e8911e4b9640..503aaa9c09590bd8e8a6c6b4b7731511b0af6d36 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;
index 65e962b6b75a4ddb511f14c6090e1995debf5834..ef9e5c31569f145d7195908c3561438d6188dfe3 100644 (file)
@@ -101,6 +101,8 @@ 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);
+struct wpabuf * wpa_bss_get_vendor_ie_multi_beacon(const struct wpa_bss *bss,
+                                                  u32 vendor_type);
 int wpa_bss_get_max_rate(const struct wpa_bss *bss);
 int wpa_bss_get_bit_rates(const struct wpa_bss *bss, u8 **rates);