OSDN Git Service

wifi: Use wpa_ctrl_cleanup() function from wpa_supplicant
authorDmitry Shmidt <dimitrysh@google.com>
Wed, 22 May 2013 23:45:57 +0000 (16:45 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Wed, 22 May 2013 23:47:40 +0000 (16:47 -0700)
Change-Id: I24af9ec380e138f24864cd9359c6901b8b29e5ee
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
wifi/Android.mk
wifi/wifi.c

index b4a6a7c..cde99d7 100644 (file)
@@ -1,8 +1,5 @@
 # Copyright 2006 The Android Open Source Project
 
-LOCAL_CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/data/misc/wifi/sockets\"
-LOCAL_CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_PREFIX=\"wpa_ctrl_\"
-
 ifdef WIFI_DRIVER_MODULE_PATH
 LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_PATH=\"$(WIFI_DRIVER_MODULE_PATH)\"
 endif
index 30933fe..c8142b7 100644 (file)
@@ -381,7 +381,7 @@ int update_ctrl_interface(const char *config_file) {
      * The <value> is deemed to be a directory if the "DIR=" form is used or
      * the value begins with "/".
      */
-    if (sptr = strstr(pbuf, "ctrl_interface=")) {
+    if ((sptr = strstr(pbuf, "ctrl_interface="))) {
         ret = 0;
         if ((!strstr(pbuf, "ctrl_interface=DIR=")) &&
                 (!strstr(pbuf, "ctrl_interface=/"))) {
@@ -484,45 +484,6 @@ int ensure_config_file_exists(const char *config_file)
     return update_ctrl_interface(config_file);
 }
 
-/**
- * wifi_wpa_ctrl_cleanup() - Delete any local UNIX domain socket files that
- * may be left over from clients that were previously connected to
- * wpa_supplicant. This keeps these files from being orphaned in the
- * event of crashes that prevented them from being removed as part
- * of the normal orderly shutdown.
- */
-void wifi_wpa_ctrl_cleanup(void)
-{
-    DIR *dir;
-    struct dirent entry;
-    struct dirent *result;
-    size_t dirnamelen;
-    size_t maxcopy;
-    char pathname[PATH_MAX];
-    char *namep;
-    char *local_socket_dir = CONFIG_CTRL_IFACE_CLIENT_DIR;
-    char *local_socket_prefix = CONFIG_CTRL_IFACE_CLIENT_PREFIX;
-
-    if ((dir = opendir(local_socket_dir)) == NULL)
-        return;
-
-    dirnamelen = (size_t)snprintf(pathname, sizeof(pathname), "%s/", local_socket_dir);
-    if (dirnamelen >= sizeof(pathname)) {
-        closedir(dir);
-        return;
-    }
-    namep = pathname + dirnamelen;
-    maxcopy = PATH_MAX - dirnamelen;
-    while (readdir_r(dir, &entry, &result) == 0 && result != NULL) {
-        if (strncmp(entry.d_name, local_socket_prefix, strlen(local_socket_prefix)) == 0) {
-            if (strlcpy(namep, entry.d_name, maxcopy) < maxcopy) {
-                unlink(pathname);
-            }
-        }
-    }
-    closedir(dir);
-}
-
 int wifi_start_supplicant(int p2p_supported)
 {
     char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
@@ -564,7 +525,7 @@ int wifi_start_supplicant(int p2p_supported)
     }
 
     /* Clear out any stale socket files that might be left over. */
-    wifi_wpa_ctrl_cleanup();
+    wpa_ctrl_cleanup();
 
     /* Reset sockets used for exiting from hung state */
     for (i=0; i<MAX_CONNS; i++) {