remove @EAP_LDFLAGS@, no longer exists
[mech_eap.orig] / libeap / src / ap / utils.c
1 /*
2  * AP mode helper functions
3  * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
4  *
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.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #include "includes.h"
16
17 #include "common.h"
18 #include "common/ieee802_11_defs.h"
19 #include "sta_info.h"
20 #include "hostapd.h"
21
22
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)
27 {
28         struct hostapd_probereq_cb *n;
29
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;
34
35         hapd->probereq_cb = n;
36         n = &hapd->probereq_cb[hapd->num_probereq_cb];
37         hapd->num_probereq_cb++;
38
39         n->cb = cb;
40         n->ctx = ctx;
41
42         return 0;
43 }
44
45
46 struct prune_data {
47         struct hostapd_data *hapd;
48         const u8 *addr;
49 };
50
51 static int prune_associations(struct hostapd_iface *iface, void *ctx)
52 {
53         struct prune_data *data = ctx;
54         struct sta_info *osta;
55         struct hostapd_data *ohapd;
56         size_t j;
57
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;
65
66                 ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED);
67         }
68
69         return 0;
70 }
71
72 /**
73  * hostapd_prune_associations - Remove extraneous associations
74  * @hapd: Pointer to BSS data for the most recent association
75  * @addr: Associated STA address
76  *
77  * This function looks through all radios and BSS's for previous
78  * (stale) associations of STA. If any are found they are removed.
79  */
80 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr)
81 {
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);
88 }