Make hostapd_for_each_interface() take context pointer as argument

This removes need for using eloop_get_user_data().
This commit is contained in:
Jouni Malinen 2009-12-19 19:07:31 +02:00
parent 2988796257
commit 9969e5a46a
5 changed files with 29 additions and 11 deletions

View file

@ -69,7 +69,8 @@ static void hostapd_prune_associations(struct hostapd_data *hapd,
struct prune_data data;
data.hapd = hapd;
data.addr = sta->addr;
hostapd_for_each_interface(prune_associations, &data);
hostapd_for_each_interface(hapd->iface->interfaces,
prune_associations, &data);
}

View file

@ -660,10 +660,12 @@ static int hostapd_wpa_auth_for_each_auth(
void *ctx, int (*cb)(struct wpa_authenticator *sm, void *ctx),
void *cb_ctx)
{
struct hostapd_data *hapd = ctx;
struct wpa_auth_iface_iter_data data;
data.cb = cb;
data.cb_ctx = cb_ctx;
return hostapd_for_each_interface(wpa_auth_iface_iter, &data);
return hostapd_for_each_interface(hapd->iface->interfaces,
wpa_auth_iface_iter, &data);
}

View file

@ -21,6 +21,7 @@ struct wpa_driver_ops;
struct wpa_ctrl_dst;
struct radius_server_data;
struct upnp_wps_device_sm;
struct hapd_interfaces;
#ifdef CONFIG_FULL_DYNAMIC_VLAN
struct full_dynamic_vlan;
@ -119,6 +120,7 @@ struct hostapd_data {
* struct hostapd_iface - hostapd per-interface data structure
*/
struct hostapd_iface {
struct hapd_interfaces *interfaces;
void *owner;
char *config_fname;
struct hostapd_config *conf;
@ -180,7 +182,8 @@ void hostapd_interface_deinit(struct hostapd_iface *iface);
int handle_reload_iface(struct hostapd_iface *iface, void *ctx);
int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx);
int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
int (*cb)(struct hostapd_iface *iface,
void *ctx), void *ctx);
int hostapd_register_probereq_cb(struct hostapd_data *hapd,

View file

@ -38,10 +38,10 @@ struct hapd_interfaces {
};
int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
int (*cb)(struct hostapd_iface *iface,
void *ctx), void *ctx)
{
struct hapd_interfaces *interfaces = eloop_get_user_data();
size_t i;
int ret;
@ -221,8 +221,9 @@ fail:
}
static struct hostapd_iface * hostapd_interface_init(const char *config_fname,
int debug)
static struct hostapd_iface *
hostapd_interface_init(struct hapd_interfaces *interfaces,
const char *config_fname, int debug)
{
struct hostapd_iface *iface;
int k;
@ -231,6 +232,7 @@ static struct hostapd_iface * hostapd_interface_init(const char *config_fname,
iface = hostapd_init(config_fname);
if (!iface)
return NULL;
iface->interfaces = interfaces;
for (k = 0; k < debug; k++) {
if (iface->bss[0]->conf->logger_stdout_level > 0)
@ -262,16 +264,18 @@ static void handle_term(int sig, void *eloop_ctx, void *signal_ctx)
*/
static void handle_reload(int sig, void *eloop_ctx, void *signal_ctx)
{
struct hapd_interfaces *interfaces = eloop_ctx;
wpa_printf(MSG_DEBUG, "Signal %d received - reloading configuration",
sig);
hostapd_for_each_interface(handle_reload_iface, NULL);
hostapd_for_each_interface(interfaces, handle_reload_iface, NULL);
}
static void handle_dump_state(int sig, void *eloop_ctx, void *signal_ctx)
{
#ifdef HOSTAPD_DUMP_STATE
hostapd_for_each_interface(handle_dump_state_iface, NULL);
struct hapd_interfaces *interfaces = eloop_ctx;
hostapd_for_each_interface(interfaces, handle_dump_state_iface, NULL);
#endif /* HOSTAPD_DUMP_STATE */
}
#endif /* CONFIG_NATIVE_WINDOWS */
@ -449,7 +453,8 @@ int main(int argc, char *argv[])
/* Initialize interfaces */
for (i = 0; i < interfaces.count; i++) {
interfaces.iface[i] = hostapd_interface_init(argv[optind + i],
interfaces.iface[i] = hostapd_interface_init(&interfaces,
argv[optind + i],
debug);
if (!interfaces.iface[i])
goto out;

View file

@ -33,7 +33,14 @@
#include "ap.h"
int hostapd_for_each_interface(int (*cb)(struct hostapd_iface *iface,
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 */