Fix hostapd wpa_msg() calls ctx for wpa_supplicant AP mode
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 29 Sep 2009 18:25:14 +0000 (21:25 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 29 Sep 2009 18:25:14 +0000 (21:25 +0300)
Need to use wpa_s pointer, not hapd pointer, for these calls.

hostapd/ctrl_iface.c
hostapd/hostapd.h
hostapd/wps_hostapd.c
wpa_supplicant/ap.c

index ff739f2..e8bb872 100644 (file)
@@ -464,6 +464,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
        hapd->ctrl_sock = s;
        eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
                                 NULL);
+       hapd->msg_ctx = hapd;
        wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
 
        return 0;
index 386889e..d0cec39 100644 (file)
@@ -62,6 +62,8 @@ struct hostapd_data {
        const struct wpa_driver_ops *driver;
        void *drv_priv;
 
+       void *msg_ctx; /* ctx for wpa_msg() calls */
+
        struct radius_client_data *radius;
        int radius_client_reconfigured;
        u32 acct_session_id_hi, acct_session_id_lo;
index 42568cd..fd2e65a 100644 (file)
@@ -147,7 +147,7 @@ static void hostapd_wps_pin_needed_cb(void *ctx, const u8 *uuid_e,
                          dev->model_number, dev->serial_number,
                          dev->categ, dev->oui, dev->sub_categ);
        if (len > 0 && len < (int) sizeof(txt))
-               wpa_msg(hapd, MSG_INFO, "%s", txt);
+               wpa_msg(hapd->msg_ctx, MSG_INFO, "%s", txt);
 
        if (hapd->conf->wps_pin_requests) {
                FILE *f;
@@ -174,7 +174,7 @@ static void hostapd_wps_reg_success_cb(void *ctx, const u8 *mac_addr,
        char uuid[40];
        if (uuid_bin2str(uuid_e, uuid, sizeof(uuid)))
                return;
-       wpa_msg(hapd, MSG_INFO, WPS_EVENT_REG_SUCCESS MACSTR " %s",
+       wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_REG_SUCCESS MACSTR " %s",
                MAC2STR(mac_addr), uuid);
 }
 
@@ -228,12 +228,12 @@ static int hostapd_wps_cred_cb(void *ctx, const struct wps_credential *cred)
                if (_buf) {
                        wpa_snprintf_hex(_buf, blen,
                                         cred->cred_attr, cred->cred_attr_len);
-                       wpa_msg(hapd, MSG_INFO, "%s%s",
+                       wpa_msg(hapd->msg_ctx, MSG_INFO, "%s%s",
                                WPS_EVENT_NEW_AP_SETTINGS, _buf);
                        os_free(_buf);
                }
        } else
-               wpa_msg(hapd, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS);
+               wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS);
 
        if (hapd->conf->wps_cred_processing == 1)
                return 0;
@@ -435,7 +435,7 @@ static void hostapd_pwd_auth_fail(struct hostapd_data *hapd,
        if (hapd->ap_pin_failures < 4)
                return;
 
-       wpa_msg(hapd, MSG_INFO, WPS_EVENT_AP_SETUP_LOCKED);
+       wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_AP_SETUP_LOCKED);
        hapd->wps->ap_setup_locked = 1;
 
        wps_registrar_update_ie(hapd->wps->registrar);
index 7886ee0..d94f099 100644 (file)
@@ -462,6 +462,8 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
                        wpa_supplicant_ap_deinit(wpa_s);
                        return -1;
                }
+
+               hapd_iface->bss[i]->msg_ctx = wpa_s;
        }
 
        if (hostapd_setup_interface(wpa_s->ap_iface)) {