From de9abffc3815449cbd8d756937030cb0353fb9f2 Mon Sep 17 00:00:00 2001 From: Dmitry Shmidt Date: Wed, 22 May 2013 16:45:57 -0700 Subject: wifi: Use wpa_ctrl_cleanup() function from wpa_supplicant Change-Id: I24af9ec380e138f24864cd9359c6901b8b29e5ee Signed-off-by: Dmitry Shmidt --- wifi/Android.mk | 3 --- wifi/wifi.c | 43 ++----------------------------------------- 2 files changed, 2 insertions(+), 44 deletions(-) (limited to 'wifi') diff --git a/wifi/Android.mk b/wifi/Android.mk index b4a6a7c..cde99d7 100644 --- a/wifi/Android.mk +++ b/wifi/Android.mk @@ -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 diff --git a/wifi/wifi.c b/wifi/wifi.c index 30933fe..c8142b7 100644 --- a/wifi/wifi.c +++ b/wifi/wifi.c @@ -381,7 +381,7 @@ int update_ctrl_interface(const char *config_file) { * The 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