From 95edd81441bf80b1560ff04d3506d3490d9c1429 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 16 Nov 2020 16:00:21 +0200 Subject: [PATCH] BSS: Add wpa_bss_get_ie_ext() wrapper This removes need from the callers to know the struct wpa_bss details for the location of the memory area for storing the IEs. Signed-off-by: Jouni Malinen --- wpa_supplicant/bss.c | 15 +++++++++++++++ wpa_supplicant/bss.h | 1 + wpa_supplicant/ctrl_iface.c | 3 +-- wpa_supplicant/wpa_supplicant.c | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 7e420485f..c64ddbced 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -1143,6 +1143,21 @@ const u8 * wpa_bss_get_ie(const struct wpa_bss *bss, u8 ie) } +/** + * wpa_bss_get_ie_ext - Fetch a specified extended IE from a BSS entry + * @bss: BSS table entry + * @ext: Information element extension identifier (WLAN_EID_EXT_*) + * 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. + */ +const u8 * wpa_bss_get_ie_ext(const struct wpa_bss *bss, u8 ext) +{ + return get_ie_ext((const u8 *) (bss + 1), bss->ie_len, ext); +} + + /** * wpa_bss_get_vendor_ie - Fetch a vendor information element from a BSS entry * @bss: BSS table entry diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h index e49858d19..b3d574eee 100644 --- a/wpa_supplicant/bss.h +++ b/wpa_supplicant/bss.h @@ -137,6 +137,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_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, u32 vendor_type); diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index aeea5ddbc..fcae260b9 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -3030,8 +3030,7 @@ static int wpa_supplicant_ctrl_iface_scan_result( if (bss_is_dmg(bss)) { const char *s; - if (get_ie_ext((const u8 *) (bss + 1), bss->ie_len, - WLAN_EID_EXT_EDMG_OPERATION)) { + if (wpa_bss_get_ie_ext(bss, WLAN_EID_EXT_EDMG_OPERATION)) { ret = os_snprintf(pos, end - pos, "[EDMG]"); if (os_snprintf_error(end - pos, ret)) return -1; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index ba7c23fa9..b51e31785 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -3640,8 +3640,8 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) } if (bss && ssid->enable_edmg) - edmg_ie_oper = get_ie_ext((const u8 *) (bss + 1), bss->ie_len, - WLAN_EID_EXT_EDMG_OPERATION); + edmg_ie_oper = wpa_bss_get_ie_ext(bss, + WLAN_EID_EXT_EDMG_OPERATION); else edmg_ie_oper = NULL;