]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_s AP mode: complete only when setup is complete
authorJohannes Berg <johannes.berg@intel.com>
Sat, 19 Mar 2011 11:11:15 +0000 (13:11 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 19 Mar 2011 11:11:15 +0000 (13:11 +0200)
The AP code might, currently only in the case of HT40, defer actual
enabling to after a scan. In this case, the wpa_s AP code gets confused.
Add a callback for it to use and make it use it to finish only when the
setup has actually completed.

With appropriate hacks in place this allows using HT40 in P2P mode.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
src/ap/hostapd.c
src/ap/hostapd.h
wpa_supplicant/ap.c

index c7faee6caf65fd4ee1c8783be46a6ad766216288..4e5eb01996ad33a940ea7f31d935f45cf0022369 100644 (file)
@@ -784,6 +784,9 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
                return -1;
        }
 
+       if (hapd->setup_complete_cb)
+               hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
+
        wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
                   iface->bss[0]->conf->iface);
 
index d649d60626bc35ab7c08b394dc3c87f4ac74d335..bb600e1584739fe91c6b06983affa006dcfd33e7 100644 (file)
@@ -145,6 +145,9 @@ struct hostapd_data {
                                  int authorized);
        void *sta_authorized_cb_ctx;
 
+       void (*setup_complete_cb)(void *ctx);
+       void *setup_complete_cb_ctx;
+
 #ifdef CONFIG_P2P
        struct p2p_data *p2p;
        struct p2p_group *p2p_group;
index fb7a10fddfdc7b216bc2290eda1da886e562a499..c4f1c00c59c43dad6a7b339436f496a9f14407c1 100644 (file)
@@ -293,6 +293,18 @@ static void ap_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
 }
 
 
+static void wpas_ap_configured_cb(void *ctx)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+
+       wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
+
+       if (wpa_s->ap_configured_cb)
+               wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx,
+                                       wpa_s->ap_configured_cb_data);
+}
+
+
 int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
                             struct wpa_ssid *ssid)
 {
@@ -427,6 +439,8 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
                        wpa_s, ssid->p2p_persistent_group,
                        ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION);
 #endif /* CONFIG_P2P */
+               hapd_iface->bss[i]->setup_complete_cb = wpas_ap_configured_cb;
+               hapd_iface->bss[i]->setup_complete_cb_ctx = wpa_s;
        }
 
        os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);
@@ -442,11 +456,6 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
        wpa_s->current_ssid = ssid;
        os_memcpy(wpa_s->bssid, wpa_s->own_addr, ETH_ALEN);
        wpa_s->assoc_freq = ssid->frequency;
-       wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
-
-       if (wpa_s->ap_configured_cb)
-               wpa_s->ap_configured_cb(wpa_s->ap_configured_cb_ctx,
-                                       wpa_s->ap_configured_cb_data);
 
        return 0;
 }