netd: softap: Add FW reload processing

Change-Id: I731c2e390187c0fa5f69779cd25d8f2388ee511e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/SoftapController.cpp b/SoftapController.cpp
index 352c353..392f11b 100644
--- a/SoftapController.cpp
+++ b/SoftapController.cpp
@@ -258,3 +258,53 @@
     }
     return ret;
 }
+
+/*
+ * Arguments:
+ *	argv[2] - interface name
+ *	argv[3] - AP or STA
+ */
+int SoftapController::fwReloadSoftap(int argc, char *argv[])
+{
+    struct iwreq wrq;
+    int fnum, ret, i = 0;
+    char *iface;
+
+    if (mSock < 0) {
+        LOGE("Softap fwrealod - failed to open socket");
+        return -1;
+    }
+    if (argc < 4) {
+        LOGE("Softap fwreload - missing arguments");
+        return -1;
+    }
+
+    iface = argv[2];
+    fnum = getPrivFuncNum(iface, "WL_FW_RELOAD");
+    if (fnum < 0) {
+        LOGE("Softap fwReload - function not supported");
+        return -1;
+    }
+
+    if (strcmp(argv[3], "AP") == 0) {
+#ifdef WIFI_DRIVER_FW_AP_PATH
+        sprintf(mBuf, "FW_PATH=%s", WIFI_DRIVER_FW_AP_PATH);
+#endif
+    } else {
+#ifdef WIFI_DRIVER_FW_STA_PATH
+        sprintf(mBuf, "FW_PATH=%s", WIFI_DRIVER_FW_STA_PATH);
+#endif
+    }
+    strncpy(wrq.ifr_name, iface, sizeof(wrq.ifr_name));
+    wrq.u.data.length = strlen(mBuf) + 1;
+    wrq.u.data.pointer = mBuf;
+    wrq.u.data.flags = 0;
+    ret = ioctl(mSock, fnum, &wrq);
+    if (ret) {
+        LOGE("Softap fwReload - failed: %d", ret);
+    }
+    else {
+        LOGD("Softap fwReload - Ok");
+    }
+    return ret;
+}