Move hostapd_prune_associations() into ap/utils.c

This commit is contained in:
Jouni Malinen 2009-12-25 14:06:26 +02:00
parent c442055ecf
commit 0aef3ec832
3 changed files with 48 additions and 46 deletions

View file

@ -837,51 +837,6 @@ void hostapd_interface_deinit(struct hostapd_iface *iface)
}
struct prune_data {
struct hostapd_data *hapd;
const u8 *addr;
};
static int prune_associations(struct hostapd_iface *iface, void *ctx)
{
struct prune_data *data = ctx;
struct sta_info *osta;
struct hostapd_data *ohapd;
size_t j;
for (j = 0; j < iface->num_bss; j++) {
ohapd = iface->bss[j];
if (ohapd == data->hapd)
continue;
osta = ap_get_sta(ohapd, data->addr);
if (!osta)
continue;
ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED);
}
return 0;
}
/**
* hostapd_prune_associations - Remove extraneous associations
* @hapd: Pointer to BSS data for the most recent association
* @sta: Pointer to the associated STA data
*
* This function looks through all radios and BSS's for previous
* (stale) associations of STA. If any are found they are removed.
*/
static void hostapd_prune_associations(struct hostapd_data *hapd,
struct sta_info *sta)
{
struct prune_data data;
data.hapd = hapd;
data.addr = sta->addr;
hostapd_for_each_interface(hapd->iface->interfaces,
prune_associations, &data);
}
/**
* hostapd_new_assoc_sta - Notify that a new station associated with the AP
* @hapd: Pointer to BSS data
@ -902,7 +857,7 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
return;
}
hostapd_prune_associations(hapd, sta);
hostapd_prune_associations(hapd, sta->addr);
/* IEEE 802.11F (IAPP) */
if (hapd->conf->ieee802_11f)

View file

@ -246,6 +246,7 @@ int hostapd_register_probereq_cb(struct hostapd_data *hapd,
void (*cb)(void *ctx, const u8 *sa,
const u8 *ie, size_t ie_len),
void *ctx);
void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
int eap_server_register_methods(void);
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);

View file

@ -15,6 +15,8 @@
#include "includes.h"
#include "common.h"
#include "common/ieee802_11_defs.h"
#include "sta_info.h"
#include "hostapd.h"
@ -39,3 +41,47 @@ int hostapd_register_probereq_cb(struct hostapd_data *hapd,
return 0;
}
struct prune_data {
struct hostapd_data *hapd;
const u8 *addr;
};
static int prune_associations(struct hostapd_iface *iface, void *ctx)
{
struct prune_data *data = ctx;
struct sta_info *osta;
struct hostapd_data *ohapd;
size_t j;
for (j = 0; j < iface->num_bss; j++) {
ohapd = iface->bss[j];
if (ohapd == data->hapd)
continue;
osta = ap_get_sta(ohapd, data->addr);
if (!osta)
continue;
ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED);
}
return 0;
}
/**
* hostapd_prune_associations - Remove extraneous associations
* @hapd: Pointer to BSS data for the most recent association
* @addr: Associated STA address
*
* This function looks through all radios and BSS's for previous
* (stale) associations of STA. If any are found they are removed.
*/
void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr)
{
struct prune_data data;
data.hapd = hapd;
data.addr = addr;
hostapd_for_each_interface(hapd->iface->interfaces,
prune_associations, &data);
}