[PATCH] wpa_cli: Add Android socket support
Dmitry Shmidt
dimitrysh
Tue Mar 8 14:41:55 PST 2011
Signed-off-by: Dmitry Shmidt <dimitrysh at google.com>
---
wpa_supplicant/wpa_cli.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 4b9e930..ddb1eda 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -25,6 +25,9 @@
#include "utils/eloop.h"
#include "utils/edit.h"
#include "common/version.h"
+#ifdef ANDROID
+#include <cutils/properties.h>
+#endif
static const char *wpa_cli_version =
@@ -90,7 +93,11 @@ static int wpa_cli_quit = 0;
static int wpa_cli_attached = 0;
static int wpa_cli_connected = 0;
static int wpa_cli_last_id = 0;
+#ifdef ANDROID
+static const char *ctrl_iface_dir = "/data/system/wpa_supplicant";
+#else
static const char *ctrl_iface_dir = "/var/run/wpa_supplicant";
+#endif
static char *ctrl_ifname = NULL;
static const char *pid_file = NULL;
static const char *action_file = NULL;
@@ -165,6 +172,11 @@ static int wpa_cli_open_connection(const char
*ifname, int attach)
if (ifname == NULL)
return -1;
+#ifdef ANDROID
+ if (access(ctrl_iface_dir, F_OK) < 0)
+ cfile = (char *)ifname;
+ else {
+#endif
flen = os_strlen(ctrl_iface_dir) + os_strlen(ifname) + 2;
cfile = os_malloc(flen);
if (cfile == NULL)
@@ -174,7 +186,9 @@ static int wpa_cli_open_connection(const char
*ifname, int attach)
os_free(cfile);
return -1;
}
-
+#ifdef ANDROID
+ }
+#endif
ctrl_conn = wpa_ctrl_open(cfile);
if (ctrl_conn == NULL) {
os_free(cfile);
@@ -185,6 +199,9 @@ static int wpa_cli_open_connection(const char
*ifname, int attach)
mon_conn = wpa_ctrl_open(cfile);
else
mon_conn = NULL;
+#ifdef ANDROID
+ if (cfile != ifname)
+#endif
os_free(cfile);
#endif /* CONFIG_CTRL_IFACE_UDP || CONFIG_CTRL_IFACE_NAMED_PIPE */
@@ -3003,8 +3020,17 @@ static char * wpa_cli_get_default_ifname(void)
#ifdef CONFIG_CTRL_IFACE_UNIX
struct dirent *dent;
DIR *dir = opendir(ctrl_iface_dir);
- if (!dir)
+ if (!dir) {
+#ifdef ANDROID
+ char ifprop[PROPERTY_VALUE_MAX];
+ if (property_get("wifi.interface", ifprop, NULL) != 0) {
+ ifname = os_strdup(ifprop);
+ printf("Using interface '%s'\n", ifname);
+ return ifname;
+ }
+#endif
return NULL;
+ }
while ((dent = readdir(dir))) {
#ifdef _DIRENT_HAVE_D_TYPE
/*
--
1.7.3.1
More information about the Hostap
mailing list