wlan: initial qcom version of wpa_supplicant_8 support library

conflicts:
        qcwcn/wpa_supplicant_8_lib/Android.mk
        qcwcn/wpa_supplicant_8_lib/driver_cmd_nl80211.c
        qcwcn/wpa_supplicant_8_lib/driver_nl80211.h

Change-Id: I36fce26e14e13a06f389a15e6b092312a700d390
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/qcwcn/wpa_supplicant_8_lib/Android.mk b/qcwcn/wpa_supplicant_8_lib/Android.mk
index af3adf9..802454c 100644
--- a/qcwcn/wpa_supplicant_8_lib/Android.mk
+++ b/qcwcn/wpa_supplicant_8_lib/Android.mk
@@ -39,10 +39,6 @@
 WPA_SRC_FILE += driver_cmd_nl80211.c
 endif
 
-ifdef CONFIG_DRIVER_WEXT
-WPA_SRC_FILE += driver_cmd_wext.c
-endif
-
 # To force sizeof(enum) = 4
 L_CFLAGS += -mabi=aapcs-linux
 
@@ -53,7 +49,7 @@
 ########################
 
 include $(CLEAR_VARS)
-LOCAL_MODULE := lib_driver_cmd_bcmdhd
+LOCAL_MODULE := lib_driver_cmd_qcwcn
 LOCAL_SHARED_LIBRARIES := libc libcutils
 LOCAL_CFLAGS := $(L_CFLAGS)
 LOCAL_SRC_FILES := $(WPA_SRC_FILE)
diff --git a/qcwcn/wpa_supplicant_8_lib/driver_cmd_nl80211.c b/qcwcn/wpa_supplicant_8_lib/driver_cmd_nl80211.c
index f7af801..dd673a9 100644
--- a/qcwcn/wpa_supplicant_8_lib/driver_cmd_nl80211.c
+++ b/qcwcn/wpa_supplicant_8_lib/driver_cmd_nl80211.c
@@ -123,86 +123,6 @@
 	return ret;
 }
 
-static int wpa_driver_set_backgroundscan_params(void *priv)
-{
-	struct i802_bss *bss = priv;
-	struct wpa_driver_nl80211_data *drv = bss->drv;
-	struct wpa_supplicant *wpa_s;
-	struct ifreq ifr;
-	android_wifi_priv_cmd priv_cmd;
-	int ret = 0, i = 0, bp;
-	char buf[WEXT_PNO_MAX_COMMAND_SIZE];
-	struct wpa_ssid *ssid_conf;
-
-	if (drv == NULL) {
-		wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__);
-		return -1;
-	}
-	if (drv->ctx == NULL) {
-		wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__);
-		return -1;
-	}
-	wpa_s = (struct wpa_supplicant *)(drv->ctx);
-	if (wpa_s->conf == NULL) {
-		wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__);
-		return -1;
-	}
-	ssid_conf = wpa_s->conf->ssid;
-
-	bp = WEXT_PNOSETUP_HEADER_SIZE;
-	os_memcpy(buf, WEXT_PNOSETUP_HEADER, bp);
-	buf[bp++] = WEXT_PNO_TLV_PREFIX;
-	buf[bp++] = WEXT_PNO_TLV_VERSION;
-	buf[bp++] = WEXT_PNO_TLV_SUBVERSION;
-	buf[bp++] = WEXT_PNO_TLV_RESERVED;
-
-	while ((i < WEXT_PNO_AMOUNT) && (ssid_conf != NULL)) {
-		/* Check that there is enough space needed for 1 more SSID, the other sections and null termination */
-		if ((bp + WEXT_PNO_SSID_HEADER_SIZE + MAX_SSID_LEN + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1) >= (int)sizeof(buf))
-			break;
-		if ((!ssid_conf->disabled) && (ssid_conf->ssid_len <= MAX_SSID_LEN)){
-			wpa_printf(MSG_DEBUG, "For PNO Scan: %s", ssid_conf->ssid);
-			buf[bp++] = WEXT_PNO_SSID_SECTION;
-			buf[bp++] = ssid_conf->ssid_len;
-			os_memcpy(&buf[bp], ssid_conf->ssid, ssid_conf->ssid_len);
-			bp += ssid_conf->ssid_len;
-			i++;
-		}
-		ssid_conf = ssid_conf->next;
-	}
-
-	buf[bp++] = WEXT_PNO_SCAN_INTERVAL_SECTION;
-	os_snprintf(&buf[bp], WEXT_PNO_SCAN_INTERVAL_LENGTH + 1, "%x", WEXT_PNO_SCAN_INTERVAL);
-	bp += WEXT_PNO_SCAN_INTERVAL_LENGTH;
-
-	buf[bp++] = WEXT_PNO_REPEAT_SECTION;
-	os_snprintf(&buf[bp], WEXT_PNO_REPEAT_LENGTH + 1, "%x", WEXT_PNO_REPEAT);
-	bp += WEXT_PNO_REPEAT_LENGTH;
-
-	buf[bp++] = WEXT_PNO_MAX_REPEAT_SECTION;
-	os_snprintf(&buf[bp], WEXT_PNO_MAX_REPEAT_LENGTH + 1, "%x", WEXT_PNO_MAX_REPEAT);
-	bp += WEXT_PNO_MAX_REPEAT_LENGTH + 1;
-
-	memset(&ifr, 0, sizeof(ifr));
-	memset(&priv_cmd, 0, sizeof(priv_cmd));
-	os_strncpy(ifr.ifr_name, bss->ifname, IFNAMSIZ);
-
-	priv_cmd.buf = buf;
-	priv_cmd.used_len = bp;
-	priv_cmd.total_len = bp;
-	ifr.ifr_data = &priv_cmd;
-
-	ret = ioctl(drv->global->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr);
-
-	if (ret < 0) {
-		wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPRIV] (pnosetup): %d", ret);
-		wpa_driver_send_hang_msg(drv);
-	} else {
-		drv_errors = 0;
-	}
-	return ret;
-}
-
 int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
 				  size_t buf_len )
 {
@@ -247,19 +167,9 @@
 			wpa_driver_send_hang_msg(drv);
 		}
 	} else { /* Use private command */
-		if (os_strcasecmp(cmd, "BGSCAN-START") == 0) {
-			ret = wpa_driver_set_backgroundscan_params(priv);
-			if (ret < 0) {
-				return ret;
-			}
-			os_memcpy(buf, "PNOFORCE 1", 11);
-		} else if (os_strcasecmp(cmd, "BGSCAN-STOP") == 0) {
-			os_memcpy(buf, "PNOFORCE 0", 11);
-		} else {
-			os_memcpy(buf, cmd, strlen(cmd) + 1);
-		}
 		memset(&ifr, 0, sizeof(ifr));
 		memset(&priv_cmd, 0, sizeof(priv_cmd));
+		os_memcpy(buf, cmd, strlen(cmd) + 1);
 		os_strncpy(ifr.ifr_name, bss->ifname, IFNAMSIZ);
 
 		priv_cmd.buf = buf;
@@ -269,7 +179,6 @@
 
 		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 {
 			drv_errors = 0;
 			ret = 0;
@@ -280,7 +189,17 @@
 			else if (os_strcasecmp(cmd, "COUNTRY") == 0)
 				wpa_supplicant_event(drv->ctx,
 					EVENT_CHANNEL_LIST_CHANGED, NULL);
-			wpa_printf(MSG_DEBUG, "%s %s len = %d, %d", __func__, buf, ret, strlen(buf));
+			else if (os_strncasecmp(cmd, "SETBAND", 7) == 0)
+				wpa_printf(MSG_DEBUG, "%s: %s ", __func__, cmd);
+			else if (os_strcasecmp(cmd, "P2P_DEV_ADDR") == 0)
+				wpa_printf(MSG_DEBUG, "%s: P2P: Device address ("MACSTR")",
+					__func__, MAC2STR(buf));
+			else if (os_strcasecmp(cmd, "P2P_SET_PS") == 0)
+				wpa_printf(MSG_DEBUG, "%s: P2P: %s ", __func__, buf);
+			else if (os_strcasecmp(cmd, "P2P_SET_NOA") == 0)
+				wpa_printf(MSG_DEBUG, "%s: P2P: %s ", __func__, buf);
+			else
+				wpa_printf(MSG_DEBUG, "%s %s len = %d, %d", __func__, buf, ret, strlen(buf));
 		}
 	}
 	return ret;
@@ -312,43 +231,3 @@
 	return wpa_driver_nl80211_driver_cmd(priv, buf, buf, strlen(buf) + 1);
 }
 
-int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
-				 const struct wpabuf *proberesp,
-				 const struct wpabuf *assocresp)
-{
-	char buf[MAX_WPSP2PIE_CMD_SIZE];
-	struct wpabuf *ap_wps_p2p_ie = NULL;
-	char *_cmd = "SET_AP_WPS_P2P_IE";
-	char *pbuf;
-	int ret = 0;
-	int i;
-	struct cmd_desc {
-		int cmd;
-		const struct wpabuf *src;
-	} cmd_arr[] = {
-		{0x1, beacon},
-		{0x2, proberesp},
-		{0x4, assocresp},
-		{-1, NULL}
-	};
-
-	wpa_printf(MSG_DEBUG, "%s: Entry", __func__);
-	for (i = 0; cmd_arr[i].cmd != -1; i++) {
-		os_memset(buf, 0, sizeof(buf));
-		pbuf = buf;
-		pbuf += sprintf(pbuf, "%s %d", _cmd, cmd_arr[i].cmd);
-		*pbuf++ = '\0';
-		ap_wps_p2p_ie = cmd_arr[i].src ?
-			wpabuf_dup(cmd_arr[i].src) : NULL;
-		if (ap_wps_p2p_ie) {
-			os_memcpy(pbuf, wpabuf_head(ap_wps_p2p_ie), wpabuf_len(ap_wps_p2p_ie));
-			ret = wpa_driver_nl80211_driver_cmd(priv, buf, buf,
-				strlen(_cmd) + 3 + wpabuf_len(ap_wps_p2p_ie));
-			wpabuf_free(ap_wps_p2p_ie);
-			if (ret < 0)
-				break;
-		}
-	}
-
-	return ret;
-}
diff --git a/qcwcn/wpa_supplicant_8_lib/driver_nl80211.h b/qcwcn/wpa_supplicant_8_lib/driver_nl80211.h
index 941eea9..72b1f81 100644
--- a/qcwcn/wpa_supplicant_8_lib/driver_nl80211.h
+++ b/qcwcn/wpa_supplicant_8_lib/driver_nl80211.h
@@ -97,6 +97,7 @@
 	unsigned int beacon_set:1;
 	unsigned int added_if_into_bridge:1;
 	unsigned int added_bridge:1;
+	unsigned int in_deinit:1;
 
 	u8 addr[ETH_ALEN];