aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-12-25 18:12:26 (GMT)
committerJouni Malinen <j@w1.fi>2009-12-25 18:12:26 (GMT)
commit1b56c26c408d3d04cd5ab8eb46d8a0b5ee8a2f7e (patch)
tree0e05c0dfe6d0db16a42c19e8791fd5e0cbb4e8e7
parent70db2ab30816bb55d9fd9f9a94461480f22bd622 (diff)
downloadhostap-1b56c26c408d3d04cd5ab8eb46d8a0b5ee8a2f7e.zip
hostap-1b56c26c408d3d04cd5ab8eb46d8a0b5ee8a2f7e.tar.gz
hostap-1b56c26c408d3d04cd5ab8eb46d8a0b5ee8a2f7e.tar.bz2
Get rid of direct hostapd_for_each_interface() calls
src/ap/*.c must not call functions in hostapd or wpa_supplicant directories directly, so avoid this by using a callback function pointer.
-rw-r--r--hostapd/main.c7
-rw-r--r--src/ap/hostapd.h9
-rw-r--r--src/ap/utils.c5
-rw-r--r--src/ap/wpa_auth_glue.c6
-rw-r--r--wpa_supplicant/ap.c15
5 files changed, 15 insertions, 27 deletions
diff --git a/hostapd/main.c b/hostapd/main.c
index 9c93a52..d69e1e6 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -43,9 +43,9 @@ struct hapd_interfaces {
};
-int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
- int (*cb)(struct hostapd_iface *iface,
- void *ctx), void *ctx)
+static int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
+ int (*cb)(struct hostapd_iface *iface,
+ void *ctx), void *ctx)
{
size_t i;
int ret;
@@ -190,6 +190,7 @@ static struct hostapd_iface * hostapd_init(const char *config_file)
goto fail;
hapd_iface->ctrl_iface_init = hostapd_ctrl_iface_init;
hapd_iface->ctrl_iface_deinit = hostapd_ctrl_iface_deinit;
+ hapd_iface->for_each_interface = hostapd_for_each_interface;
conf = hostapd_config_read(hapd_iface->config_fname);
if (conf == NULL)
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 1f753cf..25d3c3e 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -228,6 +228,10 @@ struct hostapd_iface {
int (*ctrl_iface_init)(struct hostapd_data *hapd);
void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
+
+ int (*for_each_interface)(struct hapd_interfaces *interfaces,
+ int (*cb)(struct hostapd_iface *iface,
+ void *ctx), void *ctx);
};
/* hostapd.c */
@@ -242,11 +246,6 @@ void hostapd_interface_deinit(struct hostapd_iface *iface);
void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
int reassoc);
-/* main.c */
-int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
- int (*cb)(struct hostapd_iface *iface,
- void *ctx), void *ctx);
-
/* utils.c */
int hostapd_register_probereq_cb(struct hostapd_data *hapd,
void (*cb)(void *ctx, const u8 *sa,
diff --git a/src/ap/utils.c b/src/ap/utils.c
index 1993488..7ec77ff 100644
--- a/src/ap/utils.c
+++ b/src/ap/utils.c
@@ -82,6 +82,7 @@ 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);
+ if (hapd->iface->for_each_interface)
+ hapd->iface->for_each_interface(hapd->iface->interfaces,
+ prune_associations, &data);
}
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index b2da79a..1c7b875 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -281,10 +281,12 @@ static int hostapd_wpa_auth_for_each_auth(
{
struct hostapd_data *hapd = ctx;
struct wpa_auth_iface_iter_data data;
+ if (hapd->iface->for_each_interface == NULL)
+ return -1;
data.cb = cb;
data.cb_ctx = cb_ctx;
- return hostapd_for_each_interface(hapd->iface->interfaces,
- wpa_auth_iface_iter, &data);
+ return hapd->iface->for_each_interface(hapd->iface->interfaces,
+ wpa_auth_iface_iter, &data);
}
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index a393b75..c730127 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -34,21 +34,6 @@
#include "ap.h"
-struct hapd_interfaces {
- size_t count;
- struct hostapd_iface **iface;
-};
-
-
-int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
- int (*cb)(struct hostapd_iface *iface,
- void *ctx), void *ctx)
-{
- /* TODO */
- return 0;
-}
-
-
static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
struct hostapd_config *conf)