Accumulative patch from commit 8fd0f0f323a922aa88ec720ee524f7105d3b0f64

Fix D-Bus build without CONFIG_P2P=y
nl80211: Allow AP mode to be started without monitor interface
nl80211: Process association/disassociation events in AP mode
DBus/P2P: Adding decl for PersistentGroupRemoved signal
DBus/P2P: Rectified type of SecondaryDeviceTypes in device property Get
P2P: Only call dev_lost() for devices that have been dev_found()
wpa_cli: Add missing parameter for P2P_GROUP_ADD command
wpa_supplicant: Respect PKG_CONFIG variable if set in the environment
TLS: Add support for tls_disable_time_checks=1 in client mode
hostapd: Clear keys configured when hostapd reloads configuration
Add dbus signal for information about server certification
Move peer certificate wpa_msg() calls to notify.c
wpa_supplicant AP: Disable AP mode on disassoc paths
wpa_s AP mode: Enable HT20 if driver supports it
Allow PMKSA caching to be disabled on Authenticator
FT: Disable PMKSA cache for FT-IEEE8021X
FT: Clear SME ft_used/ft_ies when disconnecting
	8fd0f0f323a922aa88ec720ee524f7105d3b0f64

Change-Id: I6ae333196c36ffa7589662d5269fabfc3b994605
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index dddac44..41dbe23 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -56,6 +56,10 @@
 {
 	struct hostapd_bss_config *bss = &conf->bss[0];
 	int pairwise;
+#ifdef CONFIG_IEEE80211N
+	struct hostapd_hw_modes *modes;
+	u16 num_modes, flags;
+#endif /* CONFIG_IEEE80211N */
 
 	conf->driver = wpa_s->driver;
 
@@ -78,9 +82,32 @@
 		return -1;
 	}
 
-	/* TODO: enable HT if driver supports it;
+	/* TODO: enable HT40 if driver supports it;
 	 * drop to 11b if driver does not support 11g */
 
+#ifdef CONFIG_IEEE80211N
+	/*
+	 * Enable HT20 if the driver supports it, by setting conf->ieee80211n.
+	 * Using default config settings for: conf->ht_op_mode_fixed,
+	 * conf->ht_capab, conf->secondary_channel, conf->require_ht
+	 */
+	modes = wpa_drv_get_hw_feature_data(wpa_s, &num_modes, &flags);
+	if (modes) {
+		struct hostapd_hw_modes *mode = NULL;
+		int i;
+		for (i = 0; i < num_modes; i++) {
+			if (modes[i].mode == conf->hw_mode) {
+				mode = &modes[i];
+				break;
+			}
+		}
+		if (mode && mode->ht_capab)
+			conf->ieee80211n = 1;
+		ieee80211_sta_free_hw_features(modes, num_modes);
+		modes = NULL;
+	}
+#endif /* CONFIG_IEEE80211N */
+
 #ifdef CONFIG_P2P
 	if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G) {
 		/* Remove 802.11b rates from supported and basic rate sets */
@@ -475,6 +502,7 @@
 
 	wpa_s->current_ssid = NULL;
 	wpa_s->assoc_freq = 0;
+	wpa_s->reassociated_connection = 0;
 #ifdef CONFIG_P2P
 	if (wpa_s->ap_iface->bss)
 		wpa_s->ap_iface->bss[0]->p2p_group = NULL;