Re-enable beaconing on interface disable+enable
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 10 Feb 2015 16:13:04 +0000 (18:13 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 10 Feb 2015 18:27:00 +0000 (20:27 +0200)
This is a step towards enabling hostapd to restart AP mode functionality
if the interface is disabled and re-enabled, e.g., with ifconfig down
and up. This commit takes care of beaconining only which may be
sufficient for open mode connection, but not for WPA2 cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/beacon.c
src/ap/drv_callbacks.c
src/ap/hostapd.h
src/drivers/driver.h
src/drivers/driver_nl80211.c

index ffe7c92..aa5821b 100644 (file)
@@ -1055,6 +1055,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
        params.beacon_ies = beacon;
        params.proberesp_ies = proberesp;
        params.assocresp_ies = assocresp;
+       params.reenable = hapd->reenable_beacon;
+       hapd->reenable_beacon = 0;
 
        if (iface->current_mode &&
            hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq,
index 40a2a9c..181cc6d 100644 (file)
@@ -1210,9 +1210,19 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 #endif /* NEED_AP_MLME */
        case EVENT_INTERFACE_ENABLED:
                wpa_msg(hapd->msg_ctx, MSG_INFO, INTERFACE_ENABLED);
+               if (hapd->disabled && hapd->started) {
+                       hapd->disabled = 0;
+                       /*
+                        * Try to re-enable interface if the driver stopped it
+                        * when the interface got disabled.
+                        */
+                       hapd->reenable_beacon = 1;
+                       ieee802_11_set_beacon(hapd);
+               }
                break;
        case EVENT_INTERFACE_DISABLED:
                wpa_msg(hapd->msg_ctx, MSG_INFO, INTERFACE_DISABLED);
+               hapd->disabled = 1;
                break;
 #ifdef CONFIG_ACS
        case EVENT_ACS_CHANNEL_SELECTED:
index 8e2c70e..75cc24e 100644 (file)
@@ -105,6 +105,8 @@ struct hostapd_data {
        struct hostapd_bss_config *conf;
        int interface_added; /* virtual interface added for this BSS */
        unsigned int started:1;
+       unsigned int disabled:1;
+       unsigned int reenable_beacon:1;
 
        u8 own_addr[ETH_ALEN];
 
index c9e860f..745f8b3 100644 (file)
@@ -1031,6 +1031,11 @@ struct wpa_driver_ap_params {
         * freq - Channel parameters for dynamic bandwidth changes
         */
        struct hostapd_freq_params *freq;
+
+       /**
+        * reenable - Whether this is to re-enable beaconing
+        */
+       int reenable;
 };
 
 struct wpa_driver_mesh_bss_params {
index adbe6eb..b970797 100644 (file)
@@ -3270,7 +3270,7 @@ static int wpa_driver_nl80211_set_ap(void *priv,
        u32 suites[10], suite;
        u32 ver;
 
-       beacon_set = bss->beacon_set;
+       beacon_set = params->reenable ? 0 : bss->beacon_set;
 
        wpa_printf(MSG_DEBUG, "nl80211: Set beacon (beacon_set=%d)",
                   beacon_set);