Add deinit_ap driver op to help wpa_supplicant AP mode use
authorJouni Malinen <jouni.malinen@atheros.com>
Sat, 16 Jan 2010 10:20:51 +0000 (12:20 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 16 Jan 2010 10:20:51 +0000 (12:20 +0200)
src/drivers/driver.h
src/drivers/driver_ndis.c
src/drivers/driver_nl80211.c
wpa_supplicant/driver_i.h

index 60304a1..f492f9f 100644 (file)
@@ -1708,6 +1708,17 @@ struct wpa_driver_ops {
         * 802.11b-only devices.
         */
        int (*disable_11b_rates)(void *priv, int disabled);
+
+       /**
+        * deinit_ap - Deinitialize AP 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 AP mode related
+        * configuration and change the driver mode to station mode to allow
+        * normal station operations like scanning to be completed.
+        */
+       int (*deinit_ap)(void *priv);
 };
 
 
index d36c0a9..29597a6 100644 (file)
@@ -3271,5 +3271,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
        NULL /* remain_on_channel */,
        NULL /* cancel_remain_on_channel */,
        NULL /* probe_req_report */,
-       NULL /* disable_11b_rates */
+       NULL /* disable_11b_rates */,
+       NULL /* deinit_ap */
 };
index a394e29..ec2dad6 100644 (file)
@@ -1959,6 +1959,9 @@ static int wpa_driver_nl80211_authenticate(
 
        drv->associated = 0;
        os_memset(drv->auth_bssid, 0, ETH_ALEN);
+       /* FIX: IBSS mode */
+       if (drv->nlmode != NL80211_IFTYPE_STATION)
+               wpa_driver_nl80211_set_mode(priv, IEEE80211_MODE_INFRA);
 
        if (wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_INFRA) < 0)
                return -1;
@@ -3632,6 +3635,9 @@ done:
        } else if (!ret && nlmode != NL80211_IFTYPE_AP) {
                /* Remove additional AP mode functionality */
                nl80211_remove_monitor_interface(drv);
+#ifndef HOSTAPD
+               drv->beacon_set = 0;
+#endif /* HOSTAPD */
        }
 
        if (ret)
@@ -4629,6 +4635,16 @@ static int wpa_driver_nl80211_disable_11b_rates(void *priv, int disabled)
 }
 
 
+static int wpa_driver_nl80211_deinit_ap(void *priv)
+{
+       struct wpa_driver_nl80211_data *drv = priv;
+       if (drv->nlmode != NL80211_IFTYPE_AP)
+               return -1;
+       wpa_driver_nl80211_del_beacon(drv);
+       return wpa_driver_nl80211_set_mode(drv, IEEE80211_MODE_INFRA);
+}
+
+
 const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .name = "nl80211",
        .desc = "Linux nl80211/cfg80211",
@@ -4684,4 +4700,5 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .alloc_interface_addr = wpa_driver_nl80211_alloc_interface_addr,
        .release_interface_addr = wpa_driver_nl80211_release_interface_addr,
        .disable_11b_rates = wpa_driver_nl80211_disable_11b_rates,
+       .deinit_ap = wpa_driver_nl80211_deinit_ap,
 };
index 5f3e149..203cbfc 100644 (file)
@@ -449,4 +449,11 @@ static inline int wpa_drv_disable_11b_rates(struct wpa_supplicant *wpa_s,
        return -1;
 }
 
+static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->driver->deinit_ap)
+               return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
+       return 0;
+}
+
 #endif /* DRIVER_I_H */