Send the FASTREASSOC command using ioctl to driver

Send FASTREASSOC command through ioctl to driver instead of using
wpa_supplicant control interface DRIVER command to remove dependency
of wpa_supplicant driver command extension library. The wpa_supplicant
driver command extension library is not available on all platforms.

Signed-off-by: Vinita Maloo <vmaloo@codeaurora.org>
diff --git a/sigma_dut.h b/sigma_dut.h
index 9520785..f605481 100644
--- a/sigma_dut.h
+++ b/sigma_dut.h
@@ -1130,6 +1130,7 @@
 int base64_encode(const char *src, size_t len, char *out, size_t out_len);
 int random_get_bytes(char *buf, size_t len);
 int get_enable_disable(const char *val);
+int wcn_driver_cmd(const char *ifname, char *buf);
 
 /* uapsd_stream.c */
 void receive_uapsd(struct sigma_stream *s);
diff --git a/sta.c b/sta.c
index 69b6766..41305a3 100644
--- a/sta.c
+++ b/sta.c
@@ -6454,14 +6454,12 @@
 			status = ERROR_SEND_STATUS;
 			goto close_mon_conn;
 		}
-		res = snprintf(buf, sizeof(buf), "DRIVER FASTREASSOC %s %d",
+		res = snprintf(buf, sizeof(buf), "FASTREASSOC %s %d",
 			       bssid, chan);
-		if (res > 0 && res < (int) sizeof(buf))
-			res = wpa_command(intf, buf);
-
-		if (res < 0 || res >= (int) sizeof(buf)) {
+		if (res < 0 || res >= (int) sizeof(buf) ||
+		    wcn_driver_cmd(intf, buf) < 0) {
 			send_resp(dut, conn, SIGMA_ERROR,
-				  "errorCode,Failed to run DRIVER FASTREASSOC");
+				  "errorCode,Failed to run FASTREASSOC");
 			goto close_mon_conn;
 		}
 		sigma_dut_print(dut, DUT_MSG_INFO,
diff --git a/utils.c b/utils.c
index e80e438..8c3dc2f 100644
--- a/utils.c
+++ b/utils.c
@@ -8,12 +8,18 @@
  */
 
 #include "sigma_dut.h"
+#include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "wpa_helpers.h"
 
 enum driver_type wifi_chip_type = DRIVER_NOT_SET;
 enum openwrt_driver_type openwrt_chip_type = OPENWRT_DRIVER_NOT_SET;
 
+struct wcn_drv_priv_cmd {
+	char *buf;
+	int used_len;
+	int total_len;
+};
 
 int file_exists(const char *fname)
 {
@@ -708,3 +714,30 @@
 		return 1;
 	return atoi(val);
 }
+
+
+int wcn_driver_cmd(const char *ifname, char *buf)
+{
+	int s, res;
+	size_t buf_len;
+	struct wcn_drv_priv_cmd priv_cmd;
+	struct ifreq ifr;
+
+	s = socket(PF_INET, SOCK_DGRAM, 0);
+	if (s < 0) {
+		perror("socket");
+		return -1;
+	}
+
+	memset(&ifr, 0, sizeof(ifr));
+	memset(&priv_cmd, 0, sizeof(priv_cmd));
+	strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+	buf_len = strlen(buf);
+	priv_cmd.buf = buf;
+	priv_cmd.used_len = buf_len;
+	priv_cmd.total_len = buf_len;
+	ifr.ifr_data = (void *) &priv_cmd;
+	res = ioctl(s, SIOCDEVPRIVATE + 1, &ifr);
+	close(s);
+	return res;
+}