From f33c8606f47f4c847d45811b68f55c288604224b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 10 Feb 2015 18:13:04 +0200 Subject: [PATCH] Re-enable beaconing on interface disable+enable 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 --- src/ap/beacon.c | 2 ++ src/ap/drv_callbacks.c | 10 ++++++++++ src/ap/hostapd.h | 2 ++ src/drivers/driver.h | 5 +++++ src/drivers/driver_nl80211.c | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index ffe7c9291..aa5821b50 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -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, diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index 40a2a9c70..181cc6d5f 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -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: diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 8e2c70eca..75cc24edb 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -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]; diff --git a/src/drivers/driver.h b/src/drivers/driver.h index c9e860f8a..745f8b3c5 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -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 { diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index adbe6eb2b..b97079772 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -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);