Get the wil6210 11ad fw version using ethtool ioctl

Signed-off-by: Alexei Avshalom Lazar <ailizaro@codeaurora.org>
diff --git a/basic.c b/basic.c
index d6a4596..f45a6fc 100644
--- a/basic.c
+++ b/basic.c
@@ -9,8 +9,12 @@
 #include "sigma_dut.h"
 #ifdef __linux__
 #include <sys/stat.h>
+#include <linux/ethtool.h>
+#include <linux/netlink.h>
+#include <linux/sockios.h>
 #endif /* __linux__ */
 #include "wpa_helpers.h"
+#include <sys/ioctl.h>
 
 
 static enum sigma_cmd_result cmd_ca_get_version(struct sigma_dut *dut,
@@ -145,13 +149,34 @@
 			get_ver("wpa_supplicant -v", wpa_supplicant_ver,
 				sizeof(wpa_supplicant_ver));
 
+		host_fw_ver[0] = '\0';
 		if (get_driver_type() == DRIVER_WCN ||
-		    get_driver_type() == DRIVER_LINUX_WCN)
+		    get_driver_type() == DRIVER_LINUX_WCN) {
 			get_ver("iwpriv wlan0 version", host_fw_ver,
 				sizeof(host_fw_ver));
-		else
-			host_fw_ver[0] = '\0';
+		} else if (get_driver_type() == DRIVER_WIL6210) {
+			struct ethtool_drvinfo drvinfo;
+			struct ifreq ifr; /* ifreq suitable for ethtool ioctl */
+			int fd; /* socket suitable for ethtool ioctl */
 
+			memset(&drvinfo, 0, sizeof(drvinfo));
+			drvinfo.cmd = ETHTOOL_GDRVINFO;
+
+			memset(&ifr, 0, sizeof(ifr));
+			strcpy(ifr.ifr_name, get_main_ifname());
+
+			fd = socket(AF_INET, SOCK_DGRAM, 0);
+			if (fd < 0)
+				fd = socket(AF_NETLINK, SOCK_RAW,
+					    NETLINK_GENERIC);
+			if (fd >= 0) {
+				ifr.ifr_data = (void *) &drvinfo;
+				if (ioctl(fd, SIOCETHTOOL, &ifr) == 0)
+					strlcpy(host_fw_ver, drvinfo.fw_version,
+						sizeof(host_fw_ver));
+				close(fd);
+			}
+		}
 		snprintf(ver_buf, sizeof(ver_buf),
 			 "drv=%s%s%s%s%s%s%s/sigma=" SIGMA_DUT_VER "%s%s",
 			 compat_ver,