From patchwork Wed Aug 3 18:03:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Shmidt X-Patchwork-Id: 136528 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 48D4CB6EEB for ; Wed, 18 Jan 2012 08:24:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C03879C1FB; Tue, 17 Jan 2012 16:24:43 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Te9feqShBuy5; Tue, 17 Jan 2012 16:24:43 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4FEC49C206; Tue, 17 Jan 2012 16:24:38 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9B1AA9C1FB for ; Tue, 17 Jan 2012 16:24:36 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d14rUcFflDM7 for ; Tue, 17 Jan 2012 16:24:32 -0500 (EST) Received: from mail-ee0-f74.google.com (mail-ee0-f74.google.com [74.125.83.74]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 8FE209C206 for ; Tue, 17 Jan 2012 16:24:31 -0500 (EST) Received: by eekb15 with SMTP id b15so105522eek.5 for ; Tue, 17 Jan 2012 13:24:30 -0800 (PST) Received: by 10.213.27.76 with SMTP id h12mr2001235ebc.5.1326835470255; Tue, 17 Jan 2012 13:24:30 -0800 (PST) Received: by 10.213.27.76 with SMTP id h12mr2001227ebc.5.1326835470109; Tue, 17 Jan 2012 13:24:30 -0800 (PST) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id g43si11823477eea.0.2012.01.17.13.24.30 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 17 Jan 2012 13:24:30 -0800 (PST) Received: from ushik.mtv.corp.google.com (ushik.mtv.corp.google.com [172.18.102.96]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id BEC535C0060 for ; Tue, 17 Jan 2012 13:24:29 -0800 (PST) Received: by ushik.mtv.corp.google.com (Postfix, from userid 57417) id 1ED2F3835D; Tue, 17 Jan 2012 13:24:29 -0800 (PST) From: Dmitry Shmidt Date: Wed, 3 Aug 2011 11:03:49 -0700 Subject: [PATCH] Allow terminate message to be sent during wpa_supplicant_cleanup() To: hostap@lists.shmoo.com Message-Id: <20120117212429.1ED2F3835D@ushik.mtv.corp.google.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Signed-off-by: Dmitry Shmidt --- wpa_supplicant/ctrl_iface.c | 2 +- wpa_supplicant/dbus/dbus_new_handlers.c | 2 +- wpa_supplicant/dbus/dbus_old_handlers.c | 2 +- wpa_supplicant/p2p_supplicant.c | 4 +- wpa_supplicant/wpa_supplicant.c | 36 +++++++++++++++++++------------ wpa_supplicant/wpa_supplicant_i.h | 3 +- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index ad3cbb9..88981d4 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -3883,7 +3883,7 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global, wpa_s = wpa_supplicant_get_iface(global, cmd); if (wpa_s == NULL) return -1; - return wpa_supplicant_remove_iface(global, wpa_s); + return wpa_supplicant_remove_iface(global, wpa_s, 0); } diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index e3526d4..3be7e00 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -576,7 +576,7 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message, wpa_s = get_iface_by_dbus_path(global, path); if (wpa_s == NULL) reply = wpas_dbus_error_iface_unknown(message); - else if (wpa_supplicant_remove_iface(global, wpa_s)) { + else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) { reply = wpas_dbus_error_unknown_error( message, "wpa_supplicant couldn't remove this " "interface."); diff --git a/wpa_supplicant/dbus/dbus_old_handlers.c b/wpa_supplicant/dbus/dbus_old_handlers.c index a7eabf3..8370a95 100644 --- a/wpa_supplicant/dbus/dbus_old_handlers.c +++ b/wpa_supplicant/dbus/dbus_old_handlers.c @@ -229,7 +229,7 @@ DBusMessage * wpas_dbus_global_remove_interface(DBusMessage *message, goto out; } - if (!wpa_supplicant_remove_iface(global, wpa_s)) { + if (!wpa_supplicant_remove_iface(global, wpa_s, 0)) { reply = wpas_dbus_new_success_reply(message); } else { reply = dbus_message_new_error(message, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 8ef3553..8d11442 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -280,7 +280,7 @@ static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s) global = wpa_s->global; ifname = os_strdup(wpa_s->ifname); type = wpas_p2p_if_type(wpa_s->p2p_group_interface); - wpa_supplicant_remove_iface(wpa_s->global, wpa_s); + wpa_supplicant_remove_iface(wpa_s->global, wpa_s, 0); wpa_s = global->ifaces; if (wpa_s && ifname) wpa_drv_if_remove(wpa_s, type, ifname); @@ -2427,7 +2427,7 @@ void wpas_p2p_deinit_global(struct wpa_global *global) break; ifname = os_strdup(tmp->ifname); type = wpas_p2p_if_type(tmp->p2p_group_interface); - wpa_supplicant_remove_iface(global, tmp); + wpa_supplicant_remove_iface(global, tmp, 0); if (ifname) wpa_drv_if_remove(wpa_s, type, ifname); os_free(ifname); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 68b80b9..54c7467 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -400,16 +400,10 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) wpa_s->l2_br = NULL; } - if (wpa_s->ctrl_iface) { - wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface); - wpa_s->ctrl_iface = NULL; - } if (wpa_s->conf != NULL) { struct wpa_ssid *ssid; for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) wpas_notify_network_removed(wpa_s, ssid); - wpa_config_free(wpa_s->conf); - wpa_s->conf = NULL; } os_free(wpa_s->confname); @@ -2393,7 +2387,7 @@ next_driver: static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s, - int notify) + int notify, int terminate) { if (wpa_s->drv_priv) { wpa_supplicant_deauthenticate(wpa_s, @@ -2405,11 +2399,24 @@ static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s, wpa_supplicant_cleanup(wpa_s); + if (wpa_s->drv_priv) + wpa_drv_deinit(wpa_s); + if (notify) wpas_notify_iface_removed(wpa_s); - if (wpa_s->drv_priv) - wpa_drv_deinit(wpa_s); + if (terminate) + wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING); + + if (wpa_s->ctrl_iface) { + wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface); + wpa_s->ctrl_iface = NULL; + } + + if (wpa_s->conf != NULL) { + wpa_config_free(wpa_s->conf); + wpa_s->conf = NULL; + } } @@ -2459,14 +2466,14 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, if (wpa_supplicant_init_iface(wpa_s, &t_iface)) { wpa_printf(MSG_DEBUG, "Failed to add interface %s", iface->ifname); - wpa_supplicant_deinit_iface(wpa_s, 0); + wpa_supplicant_deinit_iface(wpa_s, 0, 0); os_free(wpa_s); return NULL; } /* Notify the control interfaces about new iface */ if (wpas_notify_iface_added(wpa_s)) { - wpa_supplicant_deinit_iface(wpa_s, 1); + wpa_supplicant_deinit_iface(wpa_s, 1, 0); os_free(wpa_s); return NULL; } @@ -2495,7 +2502,8 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, * %wpa_supplicant is terminated. */ int wpa_supplicant_remove_iface(struct wpa_global *global, - struct wpa_supplicant *wpa_s) + struct wpa_supplicant *wpa_s, + int terminate) { struct wpa_supplicant *prev; @@ -2515,7 +2523,7 @@ int wpa_supplicant_remove_iface(struct wpa_global *global, if (global->p2p_group_formation == wpa_s) global->p2p_group_formation = NULL; - wpa_supplicant_deinit_iface(wpa_s, 1); + wpa_supplicant_deinit_iface(wpa_s, 1, terminate); os_free(wpa_s); return 0; @@ -2731,7 +2739,7 @@ void wpa_supplicant_deinit(struct wpa_global *global) #endif /* CONFIG_P2P */ while (global->ifaces) - wpa_supplicant_remove_iface(global, global->ifaces); + wpa_supplicant_remove_iface(global, global->ifaces, 1); if (global->ctrl_iface) wpa_supplicant_global_ctrl_iface_deinit(global->ctrl_iface); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 3e3b23d..bf57eb5 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -575,7 +575,8 @@ void wpa_show_license(void); struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, struct wpa_interface *iface); int wpa_supplicant_remove_iface(struct wpa_global *global, - struct wpa_supplicant *wpa_s); + struct wpa_supplicant *wpa_s, + int terminate); struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global, const char *ifname); struct wpa_global * wpa_supplicant_init(struct wpa_params *params);