List.mui: Update entries count prior to range change
[AROS.git] / workbench / network / WirelessManager / src / ap / utils.c
blob0ff48aeb37dee3dd887b96d1583753f02e4b12c3
1 /*
2 * AP mode helper functions
3 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #include "includes.h"
17 #include "common.h"
18 #include "common/ieee802_11_defs.h"
19 #include "sta_info.h"
20 #include "hostapd.h"
23 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
24 int (*cb)(void *ctx, const u8 *sa,
25 const u8 *ie, size_t ie_len),
26 void *ctx)
28 struct hostapd_probereq_cb *n;
30 n = os_realloc(hapd->probereq_cb, (hapd->num_probereq_cb + 1) *
31 sizeof(struct hostapd_probereq_cb));
32 if (n == NULL)
33 return -1;
35 hapd->probereq_cb = n;
36 n = &hapd->probereq_cb[hapd->num_probereq_cb];
37 hapd->num_probereq_cb++;
39 n->cb = cb;
40 n->ctx = ctx;
42 return 0;
46 struct prune_data {
47 struct hostapd_data *hapd;
48 const u8 *addr;
51 static int prune_associations(struct hostapd_iface *iface, void *ctx)
53 struct prune_data *data = ctx;
54 struct sta_info *osta;
55 struct hostapd_data *ohapd;
56 size_t j;
58 for (j = 0; j < iface->num_bss; j++) {
59 ohapd = iface->bss[j];
60 if (ohapd == data->hapd)
61 continue;
62 osta = ap_get_sta(ohapd, data->addr);
63 if (!osta)
64 continue;
66 ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED);
69 return 0;
72 /**
73 * hostapd_prune_associations - Remove extraneous associations
74 * @hapd: Pointer to BSS data for the most recent association
75 * @addr: Associated STA address
77 * This function looks through all radios and BSS's for previous
78 * (stale) associations of STA. If any are found they are removed.
80 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr)
82 struct prune_data data;
83 data.hapd = hapd;
84 data.addr = addr;
85 if (hapd->iface->for_each_interface)
86 hapd->iface->for_each_interface(hapd->iface->interfaces,
87 prune_associations, &data);