]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
BSS: Add wpa_bss_get_ie_beacon()
authorJouni Malinen <quic_jouni@quicinc.com>
Thu, 11 Jul 2024 20:50:55 +0000 (23:50 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 11 Jul 2024 20:50:55 +0000 (23:50 +0300)
This is a variant of wpa_bss_get_ie() to allow IEs to be checked from
only Beacon frames similarly to how wpa_bss_get_vendor_ie_beacon()
behaves for vendor specific elements.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
wpa_supplicant/bss.c
wpa_supplicant/bss.h

index 289035310231bc8b3024abf606bb2f2df67862ed..f7b4d381e26e20a9e53b66e507fd283161739eca 100644 (file)
@@ -1225,6 +1225,31 @@ const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie)
 }
 
 
+/**
+ * wpa_bss_get_ie_beacon - Fetch a specified information element from a BSS entry
+ * @bss: BSS table entry
+ * @ie: Information element identitifier (WLAN_EID_*)
+ * Returns: Pointer to the information element (id field) or %NULL if not found
+ *
+ * This function returns the first matching information element in the BSS
+ * entry.
+ *
+ * This function is like wpa_bss_get_ie(), but uses IE buffer only from Beacon
+ * frames instead of either Beacon or Probe Response frames.
+ */
+const u8 * wpa_bss_get_ie_beacon(const struct wpa_bss *bss, u8 ie)
+{
+       const u8 *ies;
+
+       if (bss->beacon_ie_len == 0)
+               return NULL;
+
+       ies = wpa_bss_ie_ptr(bss);
+       ies += bss->ie_len;
+       return get_ie(ies, bss->beacon_ie_len, ie);
+}
+
+
 /**
  * wpa_bss_get_ie_ext - Fetch a specified extended IE from a BSS entry
  * @bss: BSS table entry
index cc04963240ebbfc50bf77574db63e02bbf5d24ea..2079606a9fa474caadb4a17e3a313e70b6347a32 100644 (file)
@@ -175,6 +175,7 @@ struct wpa_bss * wpa_bss_get_id(struct wpa_supplicant *wpa_s, unsigned int id);
 struct wpa_bss * wpa_bss_get_id_range(struct wpa_supplicant *wpa_s,
                                      unsigned int idf, unsigned int idl);
 const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie);
+const u8 * wpa_bss_get_ie_beacon(const struct wpa_bss *bss, u8 ie);
 const u8 * wpa_bss_get_ie_ext(const struct wpa_bss *bss, u8 ext);
 const u8 * wpa_bss_get_vendor_ie(const struct wpa_bss *bss, u32 vendor_type);
 const u8 * wpa_bss_get_vendor_ie_beacon(const struct wpa_bss *bss,