From 89c31feb31cff1a89168d337f674fa635692f95f Mon Sep 17 00:00:00 2001 From: Manish Dharanenthiran Date: Fri, 19 Jul 2024 09:46:37 +0530 Subject: [PATCH] Relocate the declaration of the hostapd_find_by_sta() function to top The hostapd_find_by_sta() function may be utilized by multiple driver events. Therefore, it should be declared at the outset to ensure accessibility by all event handlers. No functional changes. Signed-off-by: Manish Dharanenthiran Signed-off-by: Aditya Kumar Singh --- src/ap/drv_callbacks.c | 90 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index c74e551c5..c7e43d9d4 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -250,6 +250,52 @@ out: #endif /* CONFIG_IEEE80211BE */ +#if defined(HOSTAPD) || defined(CONFIG_IEEE80211BE) +static struct hostapd_data * hostapd_find_by_sta(struct hostapd_iface *iface, + const u8 *src, bool rsn, + struct sta_info **sta_ret) +{ + struct hostapd_data *hapd; + struct sta_info *sta; + unsigned int j; + + if (sta_ret) + *sta_ret = NULL; + + for (j = 0; j < iface->num_bss; j++) { + hapd = iface->bss[j]; + sta = ap_get_sta(hapd, src); + if (sta && (sta->flags & WLAN_STA_ASSOC) && + (!rsn || sta->wpa_sm)) { + if (sta_ret) + *sta_ret = sta; + return hapd; + } +#ifdef CONFIG_IEEE80211BE + if (hapd->conf->mld_ap) { + struct hostapd_data *p_hapd; + + for_each_mld_link(p_hapd, hapd) { + if (p_hapd == hapd) + continue; + + sta = ap_get_sta(p_hapd, src); + if (sta && (sta->flags & WLAN_STA_ASSOC) && + (!rsn || sta->wpa_sm)) { + if (sta_ret) + *sta_ret = sta; + return p_hapd; + } + } + } +#endif /* CONFIG_IEEE80211BE */ + } + + return NULL; +} +#endif /* HOSTAPD || CONFIG_IEEE80211BE */ + + int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, const u8 *req_ies, size_t req_ies_len, const u8 *resp_ies, size_t resp_ies_len, @@ -1986,50 +2032,6 @@ static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr) } -static struct hostapd_data * hostapd_find_by_sta(struct hostapd_iface *iface, - const u8 *src, bool rsn, - struct sta_info **sta_ret) -{ - struct hostapd_data *hapd; - struct sta_info *sta; - unsigned int j; - - if (sta_ret) - *sta_ret = NULL; - - for (j = 0; j < iface->num_bss; j++) { - hapd = iface->bss[j]; - sta = ap_get_sta(hapd, src); - if (sta && (sta->flags & WLAN_STA_ASSOC) && - (!rsn || sta->wpa_sm)) { - if (sta_ret) - *sta_ret = sta; - return hapd; - } -#ifdef CONFIG_IEEE80211BE - if (hapd->conf->mld_ap) { - struct hostapd_data *p_hapd; - - for_each_mld_link(p_hapd, hapd) { - if (p_hapd == hapd) - continue; - - sta = ap_get_sta(p_hapd, src); - if (sta && (sta->flags & WLAN_STA_ASSOC) && - (!rsn || sta->wpa_sm)) { - if (sta_ret) - *sta_ret = sta; - return p_hapd; - } - } - } -#endif /* CONFIG_IEEE80211BE */ - } - - return NULL; -} - - static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, const u8 *data, size_t data_len, enum frame_encryption encrypted,