]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add deinit_p2p_cli op to clear P2P client driver state
authorEliad Peller <eliad@wizery.com>
Sun, 1 Apr 2012 18:41:23 +0000 (21:41 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 1 Apr 2012 18:41:23 +0000 (21:41 +0300)
On P2P group removal, the GO is deinitialized correctly (and the vif
mode is set back to sta in case of nl80211), but the P2P client mode
wasn't deinitialized, and the nl80211 vif stays in P2P client mode.

Add a new deinit_p2p_cli op (similar to deinit_ap), which currently only
sets the interface back to station mode.

Signed-hostap: Eliad Peller <eliad@wizery.com>
intended-for: hostap-1

src/drivers/driver.h
src/drivers/driver_nl80211.c
wpa_supplicant/driver_i.h
wpa_supplicant/p2p_supplicant.c

index 3c7ebe863e50fcc280b1d75806f1b4b5e92ba034..329f89a25f1eba07a5a4be9fb0530e15396a45df 100644 (file)
@@ -2018,6 +2018,16 @@ struct wpa_driver_ops {
         */
        int (*deinit_ap)(void *priv);
 
+       /**
+        * deinit_p2p_cli - Deinitialize P2P client mode
+        * @priv: Private driver interface data
+        * Returns: 0 on success, -1 on failure (or if not supported)
+        *
+        * This optional function can be used to disable P2P client mode. It
+        * can be used to change the interface type back to station mode.
+        */
+       int (*deinit_p2p_cli)(void *priv);
+
        /**
         * suspend - Notification on system suspend/hibernate event
         * @priv: Private driver interface data
index 512893327e378e7762b968a822089fa73c285ff5..6f456779b2a7b6200bc18ea3379f32d2c417eefd 100644 (file)
@@ -8303,6 +8303,16 @@ static int wpa_driver_nl80211_deinit_ap(void *priv)
 }
 
 
+static int wpa_driver_nl80211_deinit_p2p_cli(void *priv)
+{
+       struct i802_bss *bss = priv;
+       struct wpa_driver_nl80211_data *drv = bss->drv;
+       if (drv->nlmode != NL80211_IFTYPE_P2P_CLIENT)
+               return -1;
+       return wpa_driver_nl80211_set_mode(priv, NL80211_IFTYPE_STATION);
+}
+
+
 static void wpa_driver_nl80211_resume(void *priv)
 {
        struct i802_bss *bss = priv;
@@ -9028,6 +9038,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        wpa_driver_nl80211_cancel_remain_on_channel,
        .probe_req_report = wpa_driver_nl80211_probe_req_report,
        .deinit_ap = wpa_driver_nl80211_deinit_ap,
+       .deinit_p2p_cli = wpa_driver_nl80211_deinit_p2p_cli,
        .resume = wpa_driver_nl80211_resume,
        .send_ft_action = nl80211_send_ft_action,
        .signal_monitor = nl80211_signal_monitor,
index 5b1054052db7ec77ace460719faf447ea4601bbb..e1e921d2a996ad57650499e9e9a5454d05c87a7a 100644 (file)
@@ -427,6 +427,13 @@ static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
        return 0;
 }
 
+static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->driver->deinit_p2p_cli)
+               return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
+       return 0;
+}
+
 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
 {
        if (wpa_s->driver->suspend)
index ebd24867137223dcf227ea9c8d1a25ba5d513089..413d0b2778779bfc897339bab8fce7cd7bd16d72 100644 (file)
@@ -311,7 +311,10 @@ static void wpas_p2p_group_delete(struct wpa_supplicant *wpa_s)
                wpa_printf(MSG_DEBUG, "P2P: Temporary group network not "
                           "found");
        }
-       wpa_supplicant_ap_deinit(wpa_s);
+       if (wpa_s->ap_iface)
+               wpa_supplicant_ap_deinit(wpa_s);
+       else
+               wpa_drv_deinit_p2p_cli(wpa_s);
 }