wpa_supplicant_lib: Sync to wpa_supplicant b834952

Change-Id: Ie04864323f710e95ab1e2b7fa08ba99825a0c3fb
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.c b/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.c
index b19b70d..4f07836 100644
--- a/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.c
+++ b/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.c
@@ -15,7 +15,7 @@
 #include <net/if_arp.h>
 #include <net/if.h>
 
-#include "wireless_copy.h"
+#include "linux_wext.h"
 #include "common.h"
 #include "driver.h"
 #include "eloop.h"
@@ -30,6 +30,9 @@
 #include "scan.h"
 
 #include "driver_cmd_wext.h"
+#ifdef ANDROID
+#include "android_drv.h"
+#endif /* ANDROID */
 
 /**
  * wpa_driver_wext_set_scan_timeout - Set scan timeout to report scan completion
diff --git a/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.h b/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.h
index d121b2c..9fc1254 100644
--- a/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.h
+++ b/bcm4329/wpa_supplicant_8_lib/driver_cmd_wext.h
@@ -40,37 +40,4 @@
 #define WEXT_CSCAN_PASV_DWELL_TIME_MAX	3000
 #define WEXT_CSCAN_HOME_DWELL_TIME	130
 
-#define WEXT_PNOSETUP_HEADER            "PNOSETUP "
-#define WEXT_PNOSETUP_HEADER_SIZE       9
-#define WEXT_PNO_TLV_PREFIX             'S'
-#define WEXT_PNO_TLV_VERSION            '1'
-#define WEXT_PNO_TLV_SUBVERSION         '2'
-#define WEXT_PNO_TLV_RESERVED           '0'
-#define WEXT_PNO_VERSION_SIZE           4
-#define WEXT_PNO_AMOUNT                 16
-#define WEXT_PNO_SSID_SECTION           'S'
-/* SSID header size is SSID section type above + SSID length */
-#define WEXT_PNO_SSID_HEADER_SIZE       2
-#define WEXT_PNO_SCAN_INTERVAL_SECTION  'T'
-#define WEXT_PNO_SCAN_INTERVAL_LENGTH   2
-#define WEXT_PNO_SCAN_INTERVAL          30
-/* Scan interval size is scan interval section type + scan interval length above*/
-#define WEXT_PNO_SCAN_INTERVAL_SIZE     (1 + WEXT_PNO_SCAN_INTERVAL_LENGTH)
-#define WEXT_PNO_REPEAT_SECTION         'R'
-#define WEXT_PNO_REPEAT_LENGTH          1
-#define WEXT_PNO_REPEAT                 4
-/* Repeat section size is Repeat section type + Repeat value length above*/
-#define WEXT_PNO_REPEAT_SIZE            (1 + WEXT_PNO_REPEAT_LENGTH)
-#define WEXT_PNO_MAX_REPEAT_SECTION     'M'
-#define WEXT_PNO_MAX_REPEAT_LENGTH      1
-#define WEXT_PNO_MAX_REPEAT             3
-/* Max Repeat section size is Max Repeat section type + Max Repeat value length above*/
-#define WEXT_PNO_MAX_REPEAT_SIZE        (1 + WEXT_PNO_MAX_REPEAT_LENGTH)
-/* This corresponds to the size of all sections expect SSIDs */
-#define WEXT_PNO_NONSSID_SECTIONS_SIZE  (WEXT_PNO_SCAN_INTERVAL_SIZE + WEXT_PNO_REPEAT_SIZE + WEXT_PNO_MAX_REPEAT_SIZE)
-/* PNO Max command size is total of header, version, ssid and other sections + Null termination */
-#define WEXT_PNO_MAX_COMMAND_SIZE       (WEXT_PNOSETUP_HEADER_SIZE + WEXT_PNO_VERSION_SIZE \
-					+ WEXT_PNO_AMOUNT * (WEXT_PNO_SSID_HEADER_SIZE + IW_ESSID_MAX_SIZE) \
-					+ WEXT_PNO_NONSSID_SECTIONS_SIZE + 1)
-
 #endif /* DRIVER_CMD_WEXT_H */
diff --git a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_common.h b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_common.h
deleted file mode 100644
index 03ce253..0000000
--- a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_common.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Driver interaction for private interface
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- */
-#ifndef DRIVER_CMD_COMMON_H
-#define DRIVER_CMD_COMMON_H
-
-#include "config_ssid.h"
-
-#define MAX_DRV_CMD_SIZE		248
-#define DRV_NUMBER_SEQUENTIAL_ERRORS	4
-
-#define RSSI_CMD			"RSSI"
-#define LINKSPEED_CMD			"LINKSPEED"
-
-#define MAX_WPSP2PIE_CMD_SIZE		384
-
-#define WEXT_PNOSETUP_HEADER		"PNOSETUP "
-#define WEXT_PNOSETUP_HEADER_SIZE	9
-#define WEXT_PNO_TLV_PREFIX		'S'
-#define WEXT_PNO_TLV_VERSION		'1'
-#define WEXT_PNO_TLV_SUBVERSION		'2'
-#define WEXT_PNO_TLV_RESERVED		'0'
-#define WEXT_PNO_VERSION_SIZE		4
-#define WEXT_PNO_AMOUNT			16
-#define WEXT_PNO_SSID_SECTION		'S'
-/* SSID header size is SSID section type above + SSID length */
-#define WEXT_PNO_SSID_HEADER_SIZE	2
-#define WEXT_PNO_SCAN_INTERVAL_SECTION	'T'
-#define WEXT_PNO_SCAN_INTERVAL_LENGTH	2
-#define WEXT_PNO_SCAN_INTERVAL		30
-/* Scan interval size is scan interval section type + scan interval length above*/
-#define WEXT_PNO_SCAN_INTERVAL_SIZE	(1 + WEXT_PNO_SCAN_INTERVAL_LENGTH)
-#define WEXT_PNO_REPEAT_SECTION		'R'
-#define WEXT_PNO_REPEAT_LENGTH		1
-#define WEXT_PNO_REPEAT			4
-/* Repeat section size is Repeat section type + Repeat value length above*/
-#define WEXT_PNO_REPEAT_SIZE		(1 + WEXT_PNO_REPEAT_LENGTH)
-#define WEXT_PNO_MAX_REPEAT_SECTION	'M'
-#define WEXT_PNO_MAX_REPEAT_LENGTH	1
-#define WEXT_PNO_MAX_REPEAT		3
-/* Max Repeat section size is Max Repeat section type + Max Repeat value length above*/
-#define WEXT_PNO_MAX_REPEAT_SIZE	(1 + WEXT_PNO_MAX_REPEAT_LENGTH)
-/* This corresponds to the size of all sections expect SSIDs */
-#define WEXT_PNO_NONSSID_SECTIONS_SIZE	(WEXT_PNO_SCAN_INTERVAL_SIZE + WEXT_PNO_REPEAT_SIZE + WEXT_PNO_MAX_REPEAT_SIZE)
-/* PNO Max command size is total of header, version, ssid and other sections + Null termination */
-#define WEXT_PNO_MAX_COMMAND_SIZE	(WEXT_PNOSETUP_HEADER_SIZE + WEXT_PNO_VERSION_SIZE \
-					+ WEXT_PNO_AMOUNT * (WEXT_PNO_SSID_HEADER_SIZE + MAX_SSID_LEN) \
-					+ WEXT_PNO_NONSSID_SECTIONS_SIZE + 1)
-
-#endif /* DRIVER_CMD_COMMON_H */
diff --git a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_nl80211.c b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_nl80211.c
index fdaca25..ac27b53 100644
--- a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_nl80211.c
+++ b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_nl80211.c
@@ -11,16 +11,17 @@
  */
 
 #include "driver_nl80211.h"
-#include "driver_cmd_common.h"
-
 #include "wpa_supplicant_i.h"
 #include "config.h"
-
-#define WPA_EVENT_DRIVER_STATE		"CTRL-EVENT-DRIVER-STATE "
+#ifdef ANDROID
+#include "android_drv.h"
+#endif
 
 #define WPA_PS_ENABLED		0
 #define WPA_PS_DISABLED		1
 
+#define MAX_WPSP2PIE_CMD_SIZE		384
+
 typedef struct android_wifi_priv_cmd {
 	char *buf;
 	int used_len;
@@ -54,7 +55,7 @@
 	if (!msg)
 		return -1;
 
-	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
+	genlmsg_put(msg, 0, 0, drv->global->nl80211_id, 0, 0,
 		    NL80211_CMD_SET_POWER_SAVE, 0);
 
 	if (state == WPA_PS_ENABLED)
@@ -108,7 +109,7 @@
 	if (!msg)
 		return -1;
 
-	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
+	genlmsg_put(msg, 0, 0, drv->global->nl80211_id, 0, 0,
 		    NL80211_CMD_GET_POWER_SAVE, 0);
 
 	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
@@ -191,7 +192,7 @@
 	priv_cmd.total_len = bp;
 	ifr.ifr_data = &priv_cmd;
 
-	ret = ioctl(drv->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr);
+	ret = ioctl(drv->global->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr);
 
 	if (ret < 0) {
 		wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV] (pnosetup): %d", ret);
@@ -212,15 +213,15 @@
 	int ret = 0;
 
 	if (os_strcasecmp(cmd, "STOP") == 0) {
-		linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0);
+		linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
 		wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
 	} else if (os_strcasecmp(cmd, "START") == 0) {
-		linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1);
+		linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
 		wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
 	} else if (os_strcasecmp(cmd, "MACADDR") == 0) {
 		u8 macaddr[ETH_ALEN] = {};
 
-		ret = linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, macaddr);
+		ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
 		if (!ret)
 			ret = os_snprintf(buf, buf_len,
 					  "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
@@ -266,7 +267,7 @@
 		priv_cmd.total_len = buf_len;
 		ifr.ifr_data = &priv_cmd;
 
-		if ((ret = ioctl(drv->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr)) < 0) {
+		if ((ret = ioctl(drv->global->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr)) < 0) {
 			wpa_printf(MSG_ERROR, "%s: failed to issue private commands\n", __func__);
 			wpa_driver_send_hang_msg(drv);
 		} else {
@@ -274,8 +275,7 @@
 			ret = 0;
 			if ((os_strcasecmp(cmd, "LINKSPEED") == 0) ||
 			    (os_strcasecmp(cmd, "RSSI") == 0) ||
-			    (os_strcasecmp(cmd, "GETBAND") == 0) ||
-			    (os_strcasecmp(cmd, "P2P_GET_NOA") == 0))
+			    (os_strcasecmp(cmd, "GETBAND") == 0) )
 				ret = strlen(buf);
 
 			wpa_printf(MSG_DEBUG, "%s %s len = %d, %d", __func__, buf, ret, strlen(buf));
@@ -296,20 +296,8 @@
 
 int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len)
 {
-	char rbuf[MAX_DRV_CMD_SIZE];
-	char *cmd = "P2P_GET_NOA";
-	int ret;
-
-	wpa_printf(MSG_DEBUG, "%s: Entry", __func__);
-	os_memset(buf, 0, len);
-	ret = wpa_driver_nl80211_driver_cmd(priv, cmd, rbuf, sizeof(rbuf));
-	if (ret <= 0)
-		return 0;
-	ret >>= 1;
-	if (ret > (int)len)
-		ret = (int)len;
-	hexstr2bin(rbuf, buf, ret);
-	return ret;
+	/* Return 0 till we handle p2p_presence request completely in the driver */
+	return 0;
 }
 
 int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow)
diff --git a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.c b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.c
index c6d5be7..6aa435a 100644
--- a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.c
+++ b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.c
@@ -15,7 +15,7 @@
 #include <net/if_arp.h>
 #include <net/if.h>
 
-#include "wireless_copy.h"
+#include "linux_wext.h"
 #include "common.h"
 #include "driver.h"
 #include "eloop.h"
@@ -30,7 +30,12 @@
 #include "scan.h"
 
 #include "driver_cmd_wext.h"
-#include "driver_cmd_common.h"
+#ifdef ANDROID
+#include "android_drv.h"
+#endif /* ANDROID */
+
+#define RSSI_CMD			"RSSI"
+#define LINKSPEED_CMD			"LINKSPEED"
 
 /**
  * wpa_driver_wext_set_scan_timeout - Set scan timeout to report scan completion
diff --git a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.h b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.h
index 1c6e8a1..56d54fc 100644
--- a/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.h
+++ b/bcmdhd/wpa_supplicant_8_lib/driver_cmd_wext.h
@@ -17,7 +17,6 @@
 #define WEXT_NUMBER_SCAN_CHANNELS_MKK1	14
 
 #define WPA_DRIVER_WEXT_WAIT_US		400000
-#define WEXT_CSCAN_AMOUNT		9
 #define WEXT_CSCAN_BUF_LEN		360
 #define WEXT_CSCAN_HEADER		"CSCAN S\x01\x00\x00S\x00"
 #define WEXT_CSCAN_HEADER_SIZE		12
diff --git a/bcmdhd/wpa_supplicant_8_lib/driver_nl80211.h b/bcmdhd/wpa_supplicant_8_lib/driver_nl80211.h
index 7d19995..941eea9 100644
--- a/bcmdhd/wpa_supplicant_8_lib/driver_nl80211.h
+++ b/bcmdhd/wpa_supplicant_8_lib/driver_nl80211.h
@@ -67,6 +67,25 @@
 
 struct nl80211_global {
 	struct dl_list interfaces;
+	int if_add_ifindex;
+	struct netlink_data *netlink;
+	struct nl_cb *nl_cb;
+	struct nl_handle *nl;
+	int nl80211_id;
+	int ioctl_sock; /* socket for ioctl() use */
+
+	struct nl_handle *nl_event;
+};
+
+struct nl80211_wiphy_data {
+	struct dl_list list;
+	struct dl_list bsss;
+	struct dl_list drvs;
+
+	struct nl_handle *nl_beacons;
+	struct nl_cb *nl_cb;
+
+	int wiphy_idx;
 };
 
 struct i802_bss {
@@ -78,19 +97,28 @@
 	unsigned int beacon_set:1;
 	unsigned int added_if_into_bridge:1;
 	unsigned int added_bridge:1;
+
+	u8 addr[ETH_ALEN];
+
+	int freq;
+
+	struct nl_handle *nl_preq, *nl_mgmt;
+	struct nl_cb *nl_cb;
+
+	struct nl80211_wiphy_data *wiphy_data;
+	struct dl_list wiphy_list;
 };
 
 struct wpa_driver_nl80211_data {
 	struct nl80211_global *global;
 	struct dl_list list;
-	u8 addr[ETH_ALEN];
+	struct dl_list wiphy_list;
 	char phyname[32];
 	void *ctx;
-	struct netlink_data *netlink;
-	int ioctl_sock; /* socket for ioctl() use */
 	int ifindex;
 	int if_removed;
 	int if_disabled;
+	int ignore_if_down_event;
 	struct rfkill_data *rfkill;
 	struct wpa_driver_capa capa;
 	int has_capability;
@@ -99,42 +127,43 @@
 
 	int scan_complete_events;
 
-	struct nl_handle *nl_handle;
-	struct nl_handle *nl_handle_event;
-	struct nl_handle *nl_handle_preq;
-	struct nl_cache *nl_cache;
-	struct nl_cache *nl_cache_event;
-	struct nl_cache *nl_cache_preq;
 	struct nl_cb *nl_cb;
-	struct genl_family *nl80211;
 
 	u8 auth_bssid[ETH_ALEN];
 	u8 bssid[ETH_ALEN];
 	int associated;
 	u8 ssid[32];
 	size_t ssid_len;
-	int nlmode;
-	int ap_scan_as_station;
+	enum nl80211_iftype nlmode;
+	enum nl80211_iftype ap_scan_as_station;
 	unsigned int assoc_freq;
 
 	int monitor_sock;
 	int monitor_ifidx;
-	int no_monitor_iface_capab;
-	int disable_11b_rates;
+	int monitor_refcount;
 
+	unsigned int disabled_11b_rates:1;
 	unsigned int pending_remain_on_chan:1;
+	unsigned int in_interface_list:1;
+	unsigned int device_ap_sme:1;
+	unsigned int poll_command_supported:1;
+	unsigned int data_tx_status:1;
+	unsigned int scan_for_auth:1;
+	unsigned int retry_auth:1;
+	unsigned int use_monitor:1;
 
 	u64 remain_on_chan_cookie;
 	u64 send_action_cookie;
 
 	unsigned int last_mgmt_freq;
-	unsigned int ap_oper_freq;
 
 	struct wpa_driver_scan_filter *filter_ssids;
 	size_t num_filter_ssids;
 
 	struct i802_bss first_bss;
 
+	int eapol_tx_sock;
+
 #ifdef HOSTAPD
 	int eapol_sock; /* socket for EAPOL frames */
 
@@ -145,6 +174,20 @@
 	int last_freq;
 	int last_freq_ht;
 #endif /* HOSTAPD */
+
+	/* From failed authentication command */
+	int auth_freq;
+	u8 auth_bssid_[ETH_ALEN];
+	u8 auth_ssid[32];
+	size_t auth_ssid_len;
+	int auth_alg;
+	u8 *auth_ie;
+	size_t auth_ie_len;
+	u8 auth_wep_key[4][16];
+	size_t auth_wep_key_len[4];
+	int auth_wep_tx_keyidx;
+	int auth_local_state_change;
+	int auth_p2p;
 };
 
 #endif