Revert "[wpa_supplicant] Cumulative patch from b8491ae5a"

This reverts commit 878cf7bcbf2d7d8f08c3d060b8c5fbfcf0743eda.

Reason for revert: git_master/sdk_phone_armv7-sdk

Change-Id: I6070fc5c1f9c20867f6dfce90e529e35578d572e
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 45835a2..21d1398 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -236,7 +236,7 @@
 				   struct wpa_driver_mesh_bss_params *params);
 #endif /* CONFIG_MESH */
 static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-			     u16 reason);
+			     int reason);
 
 
 /* Converts nl80211_chan_width to a common format */
@@ -2010,8 +2010,9 @@
 	 */
 	drv->set_rekey_offload = 1;
 
-	drv->num_if_indices = ARRAY_SIZE(drv->default_if_indices);
+	drv->num_if_indices = sizeof(drv->default_if_indices) / sizeof(int);
 	drv->if_indices = drv->default_if_indices;
+	drv->if_indices_reason = drv->default_if_indices_reason;
 
 	drv->first_bss = os_zalloc(sizeof(*drv->first_bss));
 	if (!drv->first_bss) {
@@ -2788,6 +2789,9 @@
 	if (drv->if_indices != drv->default_if_indices)
 		os_free(drv->if_indices);
 
+	if (drv->if_indices_reason != drv->default_if_indices_reason)
+		os_free(drv->if_indices_reason);
+
 	if (drv->disabled_11b_rates)
 		nl80211_disable_11b_rates(drv, drv->ifindex, 0);
 
@@ -3278,7 +3282,7 @@
 
 
 static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
-					 u16 reason_code,
+					 int reason_code,
 					 struct nl_handle *nl_connect)
 {
 	int ret;
@@ -3300,7 +3304,7 @@
 
 
 static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss,
-					     const u8 *addr, u16 reason_code)
+					     const u8 *addr, int reason_code)
 {
 	struct wpa_driver_nl80211_data *drv = bss->drv;
 	int ret;
@@ -4167,10 +4171,8 @@
 	     nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT)))
 		goto fail;
 
-	if (drv->device_ap_sme &&
-	    (params->key_mgmt_suites & WPA_KEY_MGMT_SAE) &&
-	    nla_put_flag(msg, NL80211_ATTR_EXTERNAL_AUTH_SUPPORT))
-		goto fail;
+	if (drv->device_ap_sme && (params->key_mgmt_suites & WPA_KEY_MGMT_SAE))
+	     nla_put_flag(msg, NL80211_ATTR_EXTERNAL_AUTH_SUPPORT);
 
 	wpa_printf(MSG_DEBUG, "nl80211: pairwise_ciphers=0x%x",
 		   params->pairwise_ciphers);
@@ -4348,11 +4350,10 @@
 	if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq))
 		return -ENOBUFS;
 
-	wpa_printf(MSG_DEBUG, "  * he_enabled=%d", freq->he_enabled);
 	wpa_printf(MSG_DEBUG, "  * vht_enabled=%d", freq->vht_enabled);
 	wpa_printf(MSG_DEBUG, "  * ht_enabled=%d", freq->ht_enabled);
 
-	if (freq->vht_enabled || freq->he_enabled) {
+	if (freq->vht_enabled) {
 		enum nl80211_chan_width cw;
 
 		wpa_printf(MSG_DEBUG, "  * bandwidth=%d", freq->bandwidth);
@@ -4427,8 +4428,8 @@
 	int ret;
 
 	wpa_printf(MSG_DEBUG,
-		   "nl80211: Set freq %d (ht_enabled=%d, vht_enabled=%d, he_enabled=%d, bandwidth=%d MHz, cf1=%d MHz, cf2=%d MHz)",
-		   freq->freq, freq->ht_enabled, freq->vht_enabled, freq->he_enabled,
+		   "nl80211: Set freq %d (ht_enabled=%d, vht_enabled=%d, bandwidth=%d MHz, cf1=%d MHz, cf2=%d MHz)",
+		   freq->freq, freq->ht_enabled, freq->vht_enabled,
 		   freq->bandwidth, freq->center_freq1, freq->center_freq2);
 
 	msg = nl80211_drv_msg(drv, 0, set_chan ? NL80211_CMD_SET_CHANNEL :
@@ -4560,14 +4561,6 @@
 				goto fail;
 		}
 
-		if (params->he_capab) {
-			wpa_hexdump(MSG_DEBUG, "  * he_capab",
-				    params->he_capab, params->he_capab_len);
-			if (nla_put(msg, NL80211_ATTR_HE_CAPABILITY,
-				    params->he_capab_len, params->he_capab))
-				goto fail;
-		}
-
 		if (params->ext_capab) {
 			wpa_hexdump(MSG_DEBUG, "  * ext_capab",
 				    params->ext_capab, params->ext_capab_len);
@@ -5192,28 +5185,6 @@
 }
 
 
-static int driver_nl80211_sta_set_airtime_weight(void *priv, const u8 *addr,
-						 unsigned int weight)
-{
-	struct i802_bss *bss = priv;
-	struct nl_msg *msg;
-
-	wpa_printf(MSG_DEBUG,
-		   "nl80211: Set STA airtime weight - ifname=%s addr=" MACSTR
-		   " weight=%u", bss->ifname, MAC2STR(addr), weight);
-
-	if (!(msg = nl80211_bss_msg(bss, 0, NL80211_CMD_SET_STATION)) ||
-	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) ||
-	    nla_put_u16(msg, NL80211_ATTR_AIRTIME_WEIGHT, weight))
-		goto fail;
-
-	return send_and_recv_msgs(bss->drv, msg, NULL, NULL);
-fail:
-	nlmsg_free(msg);
-	return -ENOBUFS;
-}
-
-
 static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv,
 				 struct wpa_driver_associate_params *params)
 {
@@ -6293,36 +6264,6 @@
 }
 
 
-static void get_sta_tid_stats(struct hostap_sta_driver_data *data,
-			      struct nlattr *attr)
-{
-	struct nlattr *tid_stats[NL80211_TID_STATS_MAX + 1], *tidattr;
-	struct nlattr *txq_stats[NL80211_TXQ_STATS_MAX + 1];
-	static struct nla_policy txq_stats_policy[NL80211_TXQ_STATS_MAX + 1] = {
-		[NL80211_TXQ_STATS_BACKLOG_BYTES] = { .type = NLA_U32 },
-		[NL80211_TXQ_STATS_BACKLOG_PACKETS] = { .type = NLA_U32 },
-	};
-	int rem;
-
-	nla_for_each_nested(tidattr, attr, rem) {
-		if (nla_parse_nested(tid_stats, NL80211_TID_STATS_MAX,
-				     tidattr, NULL) != 0 ||
-		    !tid_stats[NL80211_TID_STATS_TXQ_STATS] ||
-		    nla_parse_nested(txq_stats, NL80211_TXQ_STATS_MAX,
-				     tid_stats[NL80211_TID_STATS_TXQ_STATS],
-				     txq_stats_policy) != 0)
-			continue;
-		/* sum the backlogs over all TIDs for station */
-		if (txq_stats[NL80211_TXQ_STATS_BACKLOG_BYTES])
-			data->backlog_bytes += nla_get_u32(
-				txq_stats[NL80211_TXQ_STATS_BACKLOG_BYTES]);
-		if (txq_stats[NL80211_TXQ_STATS_BACKLOG_PACKETS])
-			data->backlog_bytes += nla_get_u32(
-				txq_stats[NL80211_TXQ_STATS_BACKLOG_PACKETS]);
-	}
-}
-
-
 static int get_sta_handler(struct nl_msg *msg, void *arg)
 {
 	struct nlattr *tb[NL80211_ATTR_MAX + 1];
@@ -6340,8 +6281,6 @@
 		[NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 },
 		[NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
 		[NL80211_STA_INFO_ACK_SIGNAL] = { .type = NLA_U8 },
-		[NL80211_STA_INFO_RX_DURATION] = { .type = NLA_U64 },
-		[NL80211_STA_INFO_TX_DURATION] = { .type = NLA_U64 },
 	};
 	struct nlattr *rate[NL80211_RATE_INFO_MAX + 1];
 	static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
@@ -6399,12 +6338,6 @@
 	if (stats[NL80211_STA_INFO_TX_PACKETS])
 		data->tx_packets =
 			nla_get_u32(stats[NL80211_STA_INFO_TX_PACKETS]);
-	if (stats[NL80211_STA_INFO_RX_DURATION])
-		data->rx_airtime =
-			nla_get_u64(stats[NL80211_STA_INFO_RX_DURATION]);
-	if (stats[NL80211_STA_INFO_TX_DURATION])
-		data->tx_airtime =
-			nla_get_u64(stats[NL80211_STA_INFO_TX_DURATION]);
 	if (stats[NL80211_STA_INFO_TX_FAILED])
 		data->tx_retry_failed =
 			nla_get_u32(stats[NL80211_STA_INFO_TX_FAILED]);
@@ -6475,9 +6408,6 @@
 		}
 	}
 
-	if (stats[NL80211_STA_INFO_TID_STATS])
-		get_sta_tid_stats(data, stats[NL80211_STA_INFO_TID_STATS]);
-
 	return NL_SKIP;
 }
 
@@ -6618,7 +6548,7 @@
 
 
 static int i802_sta_deauth(void *priv, const u8 *own_addr, const u8 *addr,
-			   u16 reason)
+			   int reason)
 {
 	struct i802_bss *bss = priv;
 	struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -6653,7 +6583,7 @@
 
 
 static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr,
-			     u16 reason)
+			     int reason)
 {
 	struct i802_bss *bss = priv;
 	struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -6688,11 +6618,11 @@
 	end = pos + sizeof(buf);
 
 	for (i = 0; i < drv->num_if_indices; i++) {
-		if (!drv->if_indices[i].ifindex)
+		if (!drv->if_indices[i])
 			continue;
 		res = os_snprintf(pos, end - pos, " %d(%d)",
-				  drv->if_indices[i].ifindex,
-				  drv->if_indices[i].reason);
+				  drv->if_indices[i],
+				  drv->if_indices_reason[i]);
 		if (os_snprintf_error(end - pos, res))
 			break;
 		pos += res;
@@ -6708,7 +6638,7 @@
 		      int ifidx_reason)
 {
 	int i;
-	struct drv_nl80211_if_info *old;
+	int *old, *old_reason;
 
 	wpa_printf(MSG_DEBUG,
 		   "nl80211: Add own interface ifindex %d (ifidx_reason %d)",
@@ -6719,9 +6649,9 @@
 		return;
 	}
 	for (i = 0; i < drv->num_if_indices; i++) {
-		if (drv->if_indices[i].ifindex == 0) {
-			drv->if_indices[i].ifindex = ifidx;
-			drv->if_indices[i].reason = ifidx_reason;
+		if (drv->if_indices[i] == 0) {
+			drv->if_indices[i] = ifidx;
+			drv->if_indices_reason[i] = ifidx_reason;
 			dump_ifidx(drv);
 			return;
 		}
@@ -6732,13 +6662,29 @@
 	else
 		old = NULL;
 
+	if (drv->if_indices_reason != drv->default_if_indices_reason)
+		old_reason = drv->if_indices_reason;
+	else
+		old_reason = NULL;
+
 	drv->if_indices = os_realloc_array(old, drv->num_if_indices + 1,
-					   sizeof(*old));
+					   sizeof(int));
+	drv->if_indices_reason = os_realloc_array(old_reason,
+						  drv->num_if_indices + 1,
+						  sizeof(int));
 	if (!drv->if_indices) {
 		if (!old)
 			drv->if_indices = drv->default_if_indices;
 		else
 			drv->if_indices = old;
+	}
+	if (!drv->if_indices_reason) {
+		if (!old_reason)
+			drv->if_indices_reason = drv->default_if_indices_reason;
+		else
+			drv->if_indices_reason = old_reason;
+	}
+	if (!drv->if_indices || !drv->if_indices_reason) {
 		wpa_printf(MSG_ERROR, "Failed to reallocate memory for "
 			   "interfaces");
 		wpa_printf(MSG_ERROR, "Ignoring EAPOL on interface %d", ifidx);
@@ -6747,8 +6693,12 @@
 	if (!old)
 		os_memcpy(drv->if_indices, drv->default_if_indices,
 			  sizeof(drv->default_if_indices));
-	drv->if_indices[drv->num_if_indices].ifindex = ifidx;
-	drv->if_indices[drv->num_if_indices].reason = ifidx_reason;
+	if (!old_reason)
+		os_memcpy(drv->if_indices_reason,
+			  drv->default_if_indices_reason,
+			  sizeof(drv->default_if_indices_reason));
+	drv->if_indices[drv->num_if_indices] = ifidx;
+	drv->if_indices_reason[drv->num_if_indices] = ifidx_reason;
 	drv->num_if_indices++;
 	dump_ifidx(drv);
 }
@@ -6760,12 +6710,10 @@
 	int i;
 
 	for (i = 0; i < drv->num_if_indices; i++) {
-		if ((drv->if_indices[i].ifindex == ifidx ||
-		     ifidx == IFIDX_ANY) &&
-		    (drv->if_indices[i].reason == ifidx_reason ||
+		if ((drv->if_indices[i] == ifidx || ifidx == IFIDX_ANY) &&
+		    (drv->if_indices_reason[i] == ifidx_reason ||
 		     ifidx_reason == IFIDX_ANY)) {
-			drv->if_indices[i].ifindex = 0;
-			drv->if_indices[i].reason = 0;
+			drv->if_indices[i] = 0;
 			break;
 		}
 	}
@@ -6779,8 +6727,8 @@
 	int i;
 
 	for (i = 0; i < drv->num_if_indices; i++)
-		if (drv->if_indices[i].ifindex == ifidx &&
-		    (drv->if_indices[i].reason == ifidx_reason ||
+		if (drv->if_indices[i] == ifidx &&
+		    (drv->if_indices_reason[i] == ifidx_reason ||
 		     ifidx_reason == IFIDX_ANY))
 			return 1;
 
@@ -8422,8 +8370,8 @@
 	struct nl_msg *msg;
 	int ret;
 
-	wpa_printf(MSG_DEBUG, "nl80211: Start radar detection (CAC) %d MHz (ht_enabled=%d, vht_enabled=%d, he_enabled=%d, bandwidth=%d MHz, cf1=%d MHz, cf2=%d MHz)",
-		   freq->freq, freq->ht_enabled, freq->vht_enabled, freq->he_enabled,
+	wpa_printf(MSG_DEBUG, "nl80211: Start radar detection (CAC) %d MHz (ht_enabled=%d, vht_enabled=%d, bandwidth=%d MHz, cf1=%d MHz, cf2=%d MHz)",
+		   freq->freq, freq->ht_enabled, freq->vht_enabled,
 		   freq->bandwidth, freq->center_freq1, freq->center_freq2);
 
 	if (!(drv->capa.flags & WPA_DRIVER_FLAGS_RADAR)) {
@@ -8635,7 +8583,7 @@
 
 
 static int driver_nl80211_deauthenticate(void *priv, const u8 *addr,
-					 u16 reason_code)
+					 int reason_code)
 {
 	struct i802_bss *bss = priv;
 	return wpa_driver_nl80211_deauthenticate(bss, addr, reason_code);
@@ -8750,35 +8698,6 @@
 }
 
 
-static int nl80211_update_dh_ie(void *priv, const u8 *peer_mac,
-				u16 reason_code, const u8 *ie, size_t ie_len)
-{
-	int ret;
-	struct nl_msg *msg;
-	struct i802_bss *bss = priv;
-	struct wpa_driver_nl80211_data *drv = bss->drv;
-
-	wpa_printf(MSG_DEBUG, "nl80211: Updating DH IE peer: " MACSTR
-		   " reason %u", MAC2STR(peer_mac), reason_code);
-	if (!(msg = nl80211_bss_msg(bss, 0, NL80211_CMD_UPDATE_OWE_INFO)) ||
-	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer_mac) ||
-	    nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, reason_code) ||
-	    (ie && nla_put(msg, NL80211_ATTR_IE, ie_len, ie))) {
-		nlmsg_free(msg);
-		return -ENOBUFS;
-	}
-
-	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
-	if (ret) {
-		wpa_printf(MSG_DEBUG,
-			   "nl80211: update_dh_ie failed err=%d (%s)",
-			   ret, strerror(-ret));
-	}
-
-	return ret;
-}
-
-
 static const u8 * wpa_driver_nl80211_get_macaddr(void *priv)
 {
 	struct i802_bss *bss = priv;
@@ -9727,36 +9646,6 @@
 	return ret;
 }
 
-
-static int nl80211_probe_mesh_link(void *priv, const u8 *addr, const u8 *eth,
-				   size_t len)
-{
-	struct i802_bss *bss = priv;
-	struct wpa_driver_nl80211_data *drv = bss->drv;
-	struct nl_msg *msg;
-	int ret;
-
-	msg = nl80211_drv_msg(drv, 0, NL80211_CMD_PROBE_MESH_LINK);
-	if (!msg ||
-	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) ||
-	    nla_put(msg, NL80211_ATTR_FRAME, len, eth)) {
-		nlmsg_free(msg);
-		return -ENOBUFS;
-	}
-
-	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
-	if (ret) {
-		wpa_printf(MSG_DEBUG, "nl80211: mesh link probe to " MACSTR
-			   " failed: ret=%d (%s)",
-			   MAC2STR(addr), ret, strerror(-ret));
-	} else {
-		wpa_printf(MSG_DEBUG, "nl80211: Mesh link to " MACSTR
-			   " probed successfully", MAC2STR(addr));
-	}
-
-	return ret;
-}
-
 #endif /* CONFIG_MESH */
 
 
@@ -10928,7 +10817,7 @@
 	 * SAE) to hostapd/wpa_supplicant. Do nott send the status to drivers
 	 * which do not support AP SME or use wpa_supplicant/hostapd SME.
 	 */
-	if ((is_ap_interface(drv->nlmode) && !bss->drv->device_ap_sme) ||
+	if (!bss->drv->device_ap_sme ||
 	    (drv->capa.flags & WPA_DRIVER_FLAGS_SME))
 		return -1;
 
@@ -11035,7 +10924,6 @@
 	.sta_remove = driver_nl80211_sta_remove,
 	.hapd_send_eapol = wpa_driver_nl80211_hapd_send_eapol,
 	.sta_set_flags = wpa_driver_nl80211_sta_set_flags,
-	.sta_set_airtime_weight = driver_nl80211_sta_set_airtime_weight,
 	.hapd_init = i802_init,
 	.hapd_deinit = i802_deinit,
 	.set_wds_sta = i802_set_wds_sta,
@@ -11081,7 +10969,6 @@
 	.tdls_disable_channel_switch = nl80211_tdls_disable_channel_switch,
 #endif /* CONFIG_TDLS */
 	.update_ft_ies = wpa_driver_nl80211_update_ft_ies,
-	.update_dh_ie = nl80211_update_dh_ie,
 	.get_mac_addr = wpa_driver_nl80211_get_macaddr,
 	.get_survey = wpa_driver_nl80211_get_survey,
 	.status = wpa_driver_nl80211_status,
@@ -11104,7 +10991,6 @@
 	.init_mesh = wpa_driver_nl80211_init_mesh,
 	.join_mesh = wpa_driver_nl80211_join_mesh,
 	.leave_mesh = wpa_driver_nl80211_leave_mesh,
-	.probe_mesh_link = nl80211_probe_mesh_link,
 #endif /* CONFIG_MESH */
 	.br_add_ip_neigh = wpa_driver_br_add_ip_neigh,
 	.br_delete_ip_neigh = wpa_driver_br_delete_ip_neigh,