AP: Move hostapd_ml_get_assoc_sta() to shared

So it could be used from different contexts.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
Ilan Peer 2023-12-25 19:43:00 +02:00 committed by Jouni Malinen
parent ea401c168e
commit 9c937c8891
3 changed files with 44 additions and 46 deletions

View file

@ -85,11 +85,6 @@ static void handle_auth(struct hostapd_data *hapd,
int rssi, int from_queue); int rssi, int from_queue);
static int add_associated_sta(struct hostapd_data *hapd, static int add_associated_sta(struct hostapd_data *hapd,
struct sta_info *sta, int reassoc); struct sta_info *sta, int reassoc);
#ifdef CONFIG_IEEE80211BE
static struct sta_info *
hostapd_ml_get_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
struct hostapd_data **assoc_hapd);
#endif /* CONFIG_IEEE80211BE */
u8 * hostapd_eid_multi_ap(struct hostapd_data *hapd, u8 *eid) u8 * hostapd_eid_multi_ap(struct hostapd_data *hapd, u8 *eid)
@ -5731,47 +5726,6 @@ static void hostapd_disassoc_sta(struct hostapd_data *hapd,
} }
#ifdef CONFIG_IEEE80211BE
static struct sta_info *
hostapd_ml_get_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
struct hostapd_data **assoc_hapd)
{
struct hostapd_data *other_hapd = NULL;
struct sta_info *tmp_sta;
if (!sta->mld_info.mld_sta)
return NULL;
*assoc_hapd = hapd;
/* The station is the one on which the association was performed */
if (sta->mld_assoc_link_id == hapd->mld_link_id)
return sta;
other_hapd = hostapd_mld_get_link_bss(hapd, sta->mld_assoc_link_id);
if (!other_hapd) {
wpa_printf(MSG_DEBUG, "MLD: No link match for link_id=%u",
sta->mld_assoc_link_id);
return sta;
}
/*
* Iterate over the stations and find the one with the matching link ID
* and association ID.
*/
for (tmp_sta = other_hapd->sta_list; tmp_sta; tmp_sta = tmp_sta->next) {
if (tmp_sta->mld_assoc_link_id == sta->mld_assoc_link_id &&
tmp_sta->aid == sta->aid) {
*assoc_hapd = other_hapd;
return tmp_sta;
}
}
return sta;
}
#endif /* CONFIG_IEEE80211BE */
static bool hostapd_ml_handle_disconnect(struct hostapd_data *hapd, static bool hostapd_ml_handle_disconnect(struct hostapd_data *hapd,
struct sta_info *sta, struct sta_info *sta,
const struct ieee80211_mgmt *mgmt, const struct ieee80211_mgmt *mgmt,

View file

@ -255,5 +255,8 @@ const char * sae_get_password(struct hostapd_data *hapd,
struct sta_info *sta, const char *rx_id, struct sta_info *sta, const char *rx_id,
struct sae_password_entry **pw_entry, struct sae_password_entry **pw_entry,
struct sae_pt **s_pt, const struct sae_pk **s_pk); struct sae_pt **s_pt, const struct sae_pk **s_pk);
struct sta_info * hostapd_ml_get_assoc_sta(struct hostapd_data *hapd,
struct sta_info *sta,
struct hostapd_data **assoc_hapd);
#endif /* IEEE802_11_H */ #endif /* IEEE802_11_H */

View file

@ -1148,3 +1148,44 @@ u16 check_ext_capab(struct hostapd_data *hapd, struct sta_info *sta,
return WLAN_STATUS_SUCCESS; return WLAN_STATUS_SUCCESS;
} }
struct sta_info * hostapd_ml_get_assoc_sta(struct hostapd_data *hapd,
struct sta_info *sta,
struct hostapd_data **assoc_hapd)
{
#ifdef CONFIG_IEEE80211BE
struct hostapd_data *other_hapd = NULL;
struct sta_info *tmp_sta;
if (!sta->mld_info.mld_sta)
return NULL;
*assoc_hapd = hapd;
/* The station is the one on which the association was performed */
if (sta->mld_assoc_link_id == hapd->mld_link_id)
return sta;
other_hapd = hostapd_mld_get_link_bss(hapd, sta->mld_assoc_link_id);
if (!other_hapd) {
wpa_printf(MSG_DEBUG, "MLD: No link match for link_id=%u",
sta->mld_assoc_link_id);
return sta;
}
/*
* Iterate over the stations and find the one with the matching link ID
* and association ID.
*/
for (tmp_sta = other_hapd->sta_list; tmp_sta; tmp_sta = tmp_sta->next) {
if (tmp_sta->mld_assoc_link_id == sta->mld_assoc_link_id &&
tmp_sta->aid == sta->aid) {
*assoc_hapd = other_hapd;
return tmp_sta;
}
}
#endif /* CONFIG_IEEE80211BE */
return sta;
}