net: wireless: bcmdhd: add bssid count element in hotlist cfg am: 66d8254696 am:...
Insun Song [Thu, 16 Feb 2017 21:26:44 +0000 (21:26 +0000)]
am: 0d6d7a13c4

Change-Id: I42e151ddd7ce01ab8a09e67236548023f9a13571

bcmdhd/firmware/bcm4358/fw_bcm4358.bin
bcmdhd/firmware/bcm4358/fw_bcm4358_ap.bin
bcmdhd/wifi_hal/wifi_hal.cpp
bcmdhd/wpa_supplicant_8_lib/driver_cmd_nl80211.c

index 2ae8dab..ddc5626 100755 (executable)
Binary files a/bcmdhd/firmware/bcm4358/fw_bcm4358.bin and b/bcmdhd/firmware/bcm4358/fw_bcm4358.bin differ
index 19c26a8..77253b0 100755 (executable)
Binary files a/bcmdhd/firmware/bcm4358/fw_bcm4358_ap.bin and b/bcmdhd/firmware/bcm4358/fw_bcm4358_ap.bin differ
index d975e51..578890f 100644 (file)
@@ -259,14 +259,28 @@ wifi_error wifi_initialize(wifi_handle *handle)
 
     *handle = (wifi_handle) info;
 
-    wifi_add_membership(*handle, "scan");
-    wifi_add_membership(*handle, "mlme");
-    wifi_add_membership(*handle, "regulatory");
-    wifi_add_membership(*handle, "vendor");
+    if (wifi_init_interfaces(*handle) != WIFI_SUCCESS) {
+        ALOGE("No wifi interface found");
+        nl_socket_free(cmd_sock);
+        nl_socket_free(event_sock);
+        pthread_mutex_destroy(&info->cb_lock);
+        free(info);
+        return WIFI_ERROR_NOT_AVAILABLE;
+    }
 
-    wifi_init_interfaces(*handle);
-    // ALOGI("Found %d interfaces", info->num_interfaces);
+    if ((wifi_add_membership(*handle, "scan") < 0) ||
+        (wifi_add_membership(*handle, "mlme")  < 0) ||
+        (wifi_add_membership(*handle, "regulatory") < 0) ||
+        (wifi_add_membership(*handle, "vendor") < 0)) {
+        ALOGE("Add membership failed");
+        nl_socket_free(cmd_sock);
+        nl_socket_free(event_sock);
+        pthread_mutex_destroy(&info->cb_lock);
+        free(info);
+        return WIFI_ERROR_NOT_AVAILABLE;
+    }
 
+    // ALOGI("Found %d interfaces", info->num_interfaces);
 
     ALOGI("Initialized Wifi HAL Successfully; vendor cmd = %d", NL80211_CMD_VENDOR);
     return WIFI_SUCCESS;
@@ -318,7 +332,7 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
     char buf[64];
 
     info->cleaned_up_handler = handler;
-    if (write(info->cleanup_socks[0], "Exit", 4) < 1) {
+    if (TEMP_FAILURE_RETRY(write(info->cleanup_socks[0], "Exit", 4)) < 1) {
         // As a fallback set the cleanup flag to TRUE
         ALOGE("could not write to the cleanup socket");
     } else {
@@ -328,8 +342,9 @@ void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
         // it has rx'ed the Exit message to exit the thread.
         // As a fallback set the cleanup flag to TRUE
         memset(buf, 0, sizeof(buf));
-        int result = read(info->cleanup_socks[0], buf, sizeof(buf));
-        ALOGE("%s: Read after POLL returned %d, error no = %d", __FUNCTION__, result, errno);
+        ssize_t result = TEMP_FAILURE_RETRY(read(info->cleanup_socks[0], buf, sizeof(buf)));
+        ALOGE("%s: Read after POLL returned %zd, error no = %d (%s)", __FUNCTION__,
+               result, errno, strerror(errno));
         if (strncmp(buf, "Done", 4) == 0) {
             ALOGE("Event processing terminated");
         } else {
@@ -410,13 +425,14 @@ void wifi_event_loop(wifi_handle handle)
         pfd[0].revents = 0;
         pfd[1].revents = 0;
         // ALOGI("Polling socket");
-        int result = poll(pfd, 2, timeout);
+        int result = TEMP_FAILURE_RETRY(poll(pfd, 2, timeout));
         if (result < 0) {
             // ALOGE("Error polling socket");
         } else if (pfd[0].revents & POLLERR) {
-            ALOGE("POLL Error; error no = %d", errno);
-            int result2 = read(pfd[0].fd, buf, sizeof(buf));
-            ALOGE("Read after POLL returned %d, error no = %d", result2, errno);
+            ALOGE("POLL Error; error no = %d (%s)", errno, strerror(errno));
+            ssize_t result2 = TEMP_FAILURE_RETRY(read(pfd[0].fd, buf, sizeof(buf)));
+            ALOGE("Read after POLL returned %zd, error no = %d (%s)", result2,
+                  errno, strerror(errno));
         } else if (pfd[0].revents & POLLHUP) {
             ALOGE("Remote side hung up");
             break;
@@ -425,11 +441,12 @@ void wifi_event_loop(wifi_handle handle)
             internal_pollin_handler(handle);
         } else if (pfd[1].revents & POLLIN) {
             memset(buf, 0, sizeof(buf));
-            int result2 = read(pfd[1].fd, buf, sizeof(buf));
-            ALOGE("%s: Read after POLL returned %d, error no = %d", __FUNCTION__, result2, errno);
+            ssize_t result2 = TEMP_FAILURE_RETRY(read(pfd[1].fd, buf, sizeof(buf)));
+            ALOGE("%s: Read after POLL returned %zd, error no = %d (%s)", __FUNCTION__,
+                   result2, errno, strerror(errno));
             if (strncmp(buf, "Exit", 4) == 0) {
                 ALOGD("Got a signal to exit!!!");
-                if (write(pfd[1].fd, "Done", 4) < 1) {
+                if (TEMP_FAILURE_RETRY(write(pfd[1].fd, "Done", 4)) < 1) {
                     ALOGE("could not write to the cleanup socket");
                 }
                 break;
@@ -1138,6 +1155,9 @@ wifi_error wifi_init_interfaces(wifi_handle handle)
 
     closedir(d);
 
+    if (n == 0)
+        return WIFI_ERROR_NOT_AVAILABLE;
+
     d = opendir("/sys/class/net");
     if (d == 0)
         return WIFI_ERROR_UNKNOWN;
index 5d24799..f9dbb95 100644 (file)
@@ -168,5 +168,48 @@ int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
                                 const struct wpabuf *proberesp,
                                 const struct wpabuf *assocresp)
 {
-        return 0;
+       char *buf;
+       const struct wpabuf *ap_wps_p2p_ie = NULL;
+
+       char *_cmd = "SET_AP_WPS_P2P_IE";
+       char *pbuf;
+       int ret = 0;
+       int i, buf_len;
+       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++) {
+               ap_wps_p2p_ie = cmd_arr[i].src;
+               if (ap_wps_p2p_ie) {
+                       buf_len = strlen(_cmd) + 3 + wpabuf_len(ap_wps_p2p_ie);
+                       buf = os_zalloc(buf_len);
+                       if (NULL == buf) {
+                               wpa_printf(MSG_ERROR, "%s: Out of memory",
+                                          __func__);
+                               ret = -1;
+                               break;
+                       }
+               } else {
+                       continue;
+               }
+               pbuf = buf;
+               pbuf += snprintf(pbuf, buf_len - wpabuf_len(ap_wps_p2p_ie),
+                                "%s %d",_cmd, cmd_arr[i].cmd);
+               *pbuf++ = '\0';
+               os_memcpy(pbuf, wpabuf_head(ap_wps_p2p_ie), wpabuf_len(ap_wps_p2p_ie));
+               ret = wpa_driver_nl80211_driver_cmd(priv, buf, buf, buf_len);
+               os_free(buf);
+               if (ret < 0)
+                       break;
+       }
+
+       return ret;
 }