]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make hostapd_for_each_interface() take context pointer as argument
authorJouni Malinen <j@w1.fi>
Sat, 19 Dec 2009 17:07:31 +0000 (19:07 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 19 Dec 2009 17:07:31 +0000 (19:07 +0200)
This removes need for using eloop_get_user_data().

hostapd/drv_callbacks.c
hostapd/hostapd.c
hostapd/hostapd.h
hostapd/main.c
wpa_supplicant/ap.c

index 29c86c85cacef60790da7e68158c2a0406c43396..e1a7e4c01d8dfe1d94e696e240927d1473bd139c 100644 (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);
 }
 
 
index 701703c7e0230b33b0e7b7b37ababd4d1aa080ca..f3d1e4cb62b8c77b929a6dcdefeb92c45802ae9f 100644 (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);
 }
 
 
index e6d564ca793cec1a560cb12ebdce14738f8df64d..c9ee3ddc5eb5f306036c1369f41c741401574f83 100644 (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,
index 20efca092b6a87106d7c7cf28aa0c6bf95939321..689248367fe9f5d82db428806397b71f0bfbfd91 100644 (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;
index 9dbe719a395c8543164762ecfc988017e12839a5..cf681938b99af26cb6189f5db0a0e654a0cd5bb7 100644 (file)
 #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 */