2009-12-25 00:31:28 +01:00
|
|
|
/*
|
|
|
|
* AP mode helper functions
|
|
|
|
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-12-25 00:31:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
2009-12-25 13:06:26 +01:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2015-01-21 14:30:48 +01:00
|
|
|
#include "fst/fst.h"
|
2009-12-25 13:06:26 +01:00
|
|
|
#include "sta_info.h"
|
2009-12-25 00:31:28 +01:00
|
|
|
#include "hostapd.h"
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_register_probereq_cb(struct hostapd_data *hapd,
|
2009-12-28 12:14:58 +01:00
|
|
|
int (*cb)(void *ctx, const u8 *sa,
|
2011-07-15 19:25:53 +02:00
|
|
|
const u8 *da, const u8 *bssid,
|
2012-04-01 17:48:12 +02:00
|
|
|
const u8 *ie, size_t ie_len,
|
|
|
|
int ssi_signal),
|
2009-12-25 00:31:28 +01:00
|
|
|
void *ctx)
|
|
|
|
{
|
|
|
|
struct hostapd_probereq_cb *n;
|
|
|
|
|
2012-08-13 20:21:23 +02:00
|
|
|
n = os_realloc_array(hapd->probereq_cb, hapd->num_probereq_cb + 1,
|
|
|
|
sizeof(struct hostapd_probereq_cb));
|
2009-12-25 00:31:28 +01:00
|
|
|
if (n == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
hapd->probereq_cb = n;
|
|
|
|
n = &hapd->probereq_cb[hapd->num_probereq_cb];
|
|
|
|
hapd->num_probereq_cb++;
|
|
|
|
|
|
|
|
n->cb = cb;
|
|
|
|
n->ctx = ctx;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-25 13:06:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
2015-01-21 14:30:48 +01:00
|
|
|
#ifdef CONFIG_FST
|
|
|
|
/* Don't prune STAs belong to same FST */
|
|
|
|
if (ohapd->iface->fst &&
|
|
|
|
data->hapd->iface->fst &&
|
|
|
|
fst_are_ifaces_aggregated(ohapd->iface->fst,
|
|
|
|
data->hapd->iface->fst))
|
|
|
|
continue;
|
|
|
|
#endif /* CONFIG_FST */
|
2009-12-25 13:06:26 +01:00
|
|
|
osta = ap_get_sta(ohapd, data->addr);
|
|
|
|
if (!osta)
|
|
|
|
continue;
|
|
|
|
|
2015-04-13 16:01:21 +02:00
|
|
|
wpa_printf(MSG_INFO, "%s: Prune association for " MACSTR,
|
|
|
|
ohapd->conf->iface, MAC2STR(osta->addr));
|
2009-12-25 13:06:26 +01:00
|
|
|
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;
|
2012-08-25 11:43:27 +02:00
|
|
|
if (hapd->iface->interfaces &&
|
|
|
|
hapd->iface->interfaces->for_each_interface)
|
|
|
|
hapd->iface->interfaces->for_each_interface(
|
|
|
|
hapd->iface->interfaces, prune_associations, &data);
|
2009-12-25 13:06:26 +01:00
|
|
|
}
|