[wifi][MR3.0][wpa]Feture:update wpa_suppicant

Change-Id: I66e2d48fde6219dad924220e5f8496e4ae7a9690
diff --git a/src/lynq/packages/thirdpart/lynq-wg870/wpa_supplicant/ap.c b/src/lynq/packages/thirdpart/lynq-wg870/wpa_supplicant/ap.c
index 6d1be11..21f7531 100755
--- a/src/lynq/packages/thirdpart/lynq-wg870/wpa_supplicant/ap.c
+++ b/src/lynq/packages/thirdpart/lynq-wg870/wpa_supplicant/ap.c
@@ -38,11 +38,6 @@
 #include "ap/sta_info.h"
 #include "notify.h"
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
-#ifdef WAPI_AP
-void brcm_wapiap_initialize(void *ctx, int wapiap_tx_sock, struct i802_bss *bss, struct wpa_ssid *ssid);
-#endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 
 #ifdef CONFIG_WPS
 static void wpas_wps_ap_pin_timeout(void *eloop_data, void *user_ctx);
@@ -90,15 +85,11 @@
 
 	if (hostapd_get_oper_chwidth(conf) == CHANWIDTH_80P80MHZ) {
 		ieee80211_freq_to_chan(ssid->vht_center_freq2,
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_AP_VHT
 				       &conf->vht_oper_centr_freq_seg1_idx);
 #else /* CONFIG_AP_VHT */
 				       &freq_seg_idx);
 #endif /* CONFIG_AP_VHT */
-#else
-				       &freq_seg_idx);
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 		hostapd_set_oper_centr_freq_seg1_idx(conf, freq_seg_idx);
 	}
 
@@ -116,7 +107,6 @@
 		return;
 	}
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #if defined(CONFIG_BRCM_RSDB)
 	if (wpa_s->conf->p2p_pref_freq_2g && wpa_s->conf->p2p_pref_freq_5g) {
 		int freq, num;
@@ -137,7 +127,6 @@
 		}
 	}
 #endif /* CONFIG_BRCM_RSDB */
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 #ifdef CONFIG_P2P
 	switch (hostapd_get_oper_chwidth(conf)) {
 	case CHANWIDTH_80MHZ:
@@ -211,7 +200,6 @@
 	return mode;
 }
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_SAE
 static int wpas_conf_ap_sae_password(struct hostapd_bss_config *bss, const char *sae_pwd)
 {
@@ -236,7 +224,6 @@
 	return -1;
 }
 #endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 
 int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
 			      struct wpa_ssid *ssid,
@@ -250,7 +237,6 @@
 			   ssid->frequency);
 		return -1;
 	}
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #if defined(CONFIG_BRCM_RSDB)
 	if (wpa_s->conf->p2p_pref_freq_2g && wpa_s->conf->p2p_pref_freq_5g) {
 		int freq, num;
@@ -271,7 +257,6 @@
 		}
 	}
 #endif /* CONFIG_BRCM_RSDB */
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 
 	/*
 	 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
@@ -352,7 +337,6 @@
 
 			if (!ssid->p2p_group &&
 			    (mode->ht_capab &
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_CY_AUTO_SET_BW
 			     /* Fix to resolve softap creation failure on 5G/80 */
 			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
@@ -363,10 +347,6 @@
 			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
 				conf->secondary_channel = ssid->ht40;
 #endif /* CONFIG_CY_AUTO_SET_BW */
-#else
-			     HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
-				conf->secondary_channel = ssid->ht40;
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 				wpa_printf(MSG_DEBUG,
 					   "HT secondary channel offset %d for AP",
 					   conf->secondary_channel);
@@ -707,15 +687,6 @@
 	 * require user interaction to actually use it. Only the internal
 	 * Registrar is supported.
 	 */
-#ifdef CONFIG_DRIVER_NL80211_IFX
-#ifdef WAPI_AP
-        /* Disable WPS feature if WAPI-AP is enabled */
-        if (bss->wpa_key_mgmt == WPA_KEY_MGMT_WAPI_PSK) {
-                wpa_printf(MSG_DEBUG, "%s: Disabling WPS feature\n", __FUNCTION__);
-                goto no_wps;
-        }
-#endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	if (bss->ssid.security_policy != SECURITY_WPA_PSK &&
 	    bss->ssid.security_policy != SECURITY_PLAINTEXT)
 		goto no_wps;
@@ -923,7 +894,10 @@
 	struct hostapd_iface *hapd_iface;
 	struct hostapd_config *conf;
 	size_t i;
-#ifdef CONFIG_DRIVER_NL80211_IFX
+#if !defined(HOSTAPD)
+	struct wpa_global *global;
+	struct wpa_supplicant *wpa_last;
+#endif /* !HOSTAPD && CONFIG_DRIVER_NL80211_IFX */
 #ifdef CONFIG_CY_AUTO_SET_BW
 	/* Fix to create supplicant based softap on best channel
 	instead of random channel when specifying freq=2 or freq=5 */
@@ -931,32 +905,23 @@
 	int chan,freq;
 	u8 opclass;
 #endif /* CONFIG_CY_AUTO_SET_BW */
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 
 	if (ssid->ssid == NULL || ssid->ssid_len == 0) {
 		wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
 		return -1;
 	}
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_BRCM_AUTOMOTIVE
 	if (ssid->vht == -1 && ssid->ht40 == -1) {
 		wpa_printf(MSG_ERROR, "No Channel width configured for AP mode");
 		return -1;
 	}
 #endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	wpa_supplicant_ap_deinit(wpa_s);
 
 	wpa_printf(MSG_DEBUG, "Setting up AP (SSID='%s')",
 		   wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
-#ifdef WAPI_AP
-        if (ssid->key_mgmt & WPA_KEY_MGMT_WAPI_PSK)
-                brcm_wapiap_initialize(wpa_s, wpa_s->wapi_tx_sock, wpa_s->wapi_bss, ssid);
-#endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	os_memset(&params, 0, sizeof(params));
 	params.ssid = ssid->ssid;
 	params.ssid_len = ssid->ssid_len;
@@ -969,7 +934,6 @@
 	default:
 		return -1;
 	}
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_CY_AUTO_SET_BW
 	/* Fix to create supplicant based softap on best channel
 	instead of random channel when specifying freq=2 or freq=5 */
@@ -978,6 +942,10 @@
 		return -1;
 	hapd_iface->owner = wpa_s;
 	hapd_iface->drv_flags = wpa_s->drv_flags;
+	/* Support for 4-way handshake offload to internal supplicant
+	 * for WPA/WPA2-PSK
+	 */
+	hapd_iface->drv_flags2 = wpa_s->drv_flags2;
 	hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
 	hapd_iface->extended_capa = wpa_s->extended_capa;
 	hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
@@ -1008,10 +976,6 @@
 	if (ssid->frequency == 0)
 		ssid->frequency = 2462; /* default channel 11 */
 #endif /* CONFIG_CY_AUTO_SET_BW */
-#else
-	if (ssid->frequency == 0)
-		ssid->frequency = 2462; /* default channel 11 */
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	params.freq.freq = ssid->frequency;
 
 	if ((ssid->mode == WPAS_MODE_AP || ssid->mode == WPAS_MODE_P2P_GO) &&
@@ -1032,12 +996,6 @@
 	params.wpa_proto = ssid->proto;
 	if (ssid->key_mgmt & WPA_KEY_MGMT_PSK)
 		wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
-#ifdef CONFIG_DRIVER_NL80211_IFX
-#ifdef WAPI_AP
-        else if (ssid->key_mgmt & WPA_KEY_MGMT_WAPI_PSK)
-                wpa_s->key_mgmt = WPA_KEY_MGMT_WAPI_PSK;
-#endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	else
 		wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
 	params.key_mgmt_suite = wpa_s->key_mgmt;
@@ -1079,23 +1037,6 @@
 		return -1;
 	}
 
-#ifndef CONFIG_DRIVER_NL80211_IFX
-	wpa_s->ap_iface = hapd_iface = hostapd_alloc_iface();
-	if (hapd_iface == NULL)
-		return -1;
-	hapd_iface->owner = wpa_s;
-	hapd_iface->drv_flags = wpa_s->drv_flags;
-	hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
-	hapd_iface->extended_capa = wpa_s->extended_capa;
-	hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
-	hapd_iface->extended_capa_len = wpa_s->extended_capa_len;
-
-	wpa_s->ap_iface->conf = conf = hostapd_config_defaults();
-	if (conf == NULL) {
-		wpa_supplicant_ap_deinit(wpa_s);
-		return -1;
-	}
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 
 	os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params,
 		  wpa_s->conf->wmm_ac_params,
@@ -1109,13 +1050,11 @@
 		conf->bss[0]->wmm_uapsd = 1;
 	}
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_BRCM_RSN_CNTRS
 	if (wpa_s->conf->replay_cntrs) {
 		conf->bss[0]->replay_cntrs = wpa_s->conf->replay_cntrs;
 	}
 #endif /* CONFIG_BRCM_RSN_CNTRS */
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	if (wpa_supplicant_conf_ap(wpa_s, ssid, conf)) {
 		wpa_printf(MSG_ERROR, "Failed to create AP configuration");
 		wpa_supplicant_ap_deinit(wpa_s);
@@ -1174,12 +1113,10 @@
 		hapd_iface->bss[i]->ext_eapol_frame_io =
 			wpa_s->ext_eapol_frame_io;
 #endif /* CONFIG_TESTING_OPTIONS */
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_BRCM_AUTOMOTIVE
 		if (wpa_s->conf)
 			hapd_iface->bss[i]->conf->ignore_broadcast_ssid = wpa_s->conf->ignore_broadcast_ssid;
 #endif /* CONFIG_BRCM_AUTOMOTIVE */
-#endif /* CONFIG_DRIVER_NL80211_IFX */
 	}
 
 	os_memcpy(hapd_iface->bss[0]->own_addr, wpa_s->own_addr, ETH_ALEN);
@@ -1201,6 +1138,27 @@
 	}
 #endif /* CONFIG_P2P && CONFIG_ACS */
 
+#if !defined(HOSTAPD)
+	if (!wpa_s->global->rsdb_flag) {
+		global = wpa_s->global;
+		for (wpa_last = global->ifaces; wpa_last; wpa_last = wpa_last->next)
+			if (os_strcmp(wpa_s->ifname, wpa_last->ifname) == 0 ||
+				os_strcmp(wpa_last->ifname, "wlan0") == 0 ||
+				os_strcmp(wpa_last->ifname, "p2p-dev-wlan0") == 0)
+				continue;
+			else if (wpa_last->ap_iface->bss != NULL &&
+					wpa_last->ap_iface->bss[0]->num_sta > 0) {
+					ssid = wpa_config_get_network(wpa_s->conf, 0);
+					if (ssid == NULL)
+						return;
+					if (ssid->disabled == 2)
+						return;
+					wpa_supplicant_disable_network(wpa_s, ssid);
+					return -1;
+			}
+	}
+#endif /* !HOSTAPD && CONFIG_DRIVER_NL80211_IFX */
+
 	if (hostapd_setup_interface(wpa_s->ap_iface)) {
 		wpa_printf(MSG_ERROR, "Failed to initialize AP interface");
 		wpa_supplicant_ap_deinit(wpa_s);
@@ -1715,7 +1673,7 @@
 	if (!iface)
 		return;
 	wpa_s->assoc_freq = freq;
-#if defined(CONFIG_DRIVER_NL80211_IFX) && defined(CONFIG_BRCM_GO_CH_SWITCH_NOTIFY)
+#if defined(CONFIG_BRCM_GO_CH_SWITCH_NOTIFY)
 	wpa_s->current_ssid->frequency = freq;
 #else
 	if (wpa_s->current_ssid)
@@ -2004,7 +1962,6 @@
 }
 
 
-#ifdef CONFIG_DRIVER_NL80211_IFX
 #ifdef CONFIG_BRCM_AUTOMOTIVE
 void wpas_ap_set_interworking_ie(struct wpa_supplicant *wpa_s)
 {
@@ -2013,4 +1970,3 @@
 	wpa_printf(MSG_DEBUG, "%s: ret:%d\n", __FUNCTION__, ret);
 }
 #endif
-#endif /* CONFIG_DRIVER_NL80211_IFX */