wpa_cli: Add Android socket support
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
parent
5bbf9f1086
commit
b1001e4c45
1 changed files with 33 additions and 10 deletions
|
@ -25,6 +25,9 @@
|
||||||
#include "utils/eloop.h"
|
#include "utils/eloop.h"
|
||||||
#include "utils/edit.h"
|
#include "utils/edit.h"
|
||||||
#include "common/version.h"
|
#include "common/version.h"
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include <cutils/properties.h>
|
||||||
|
#endif /* ANDROID */
|
||||||
|
|
||||||
|
|
||||||
static const char *wpa_cli_version =
|
static const char *wpa_cli_version =
|
||||||
|
@ -159,20 +162,31 @@ static int wpa_cli_open_connection(const char *ifname, int attach)
|
||||||
else
|
else
|
||||||
mon_conn = NULL;
|
mon_conn = NULL;
|
||||||
#else /* CONFIG_CTRL_IFACE_UDP || CONFIG_CTRL_IFACE_NAMED_PIPE */
|
#else /* CONFIG_CTRL_IFACE_UDP || CONFIG_CTRL_IFACE_NAMED_PIPE */
|
||||||
char *cfile;
|
char *cfile = NULL;
|
||||||
int flen, res;
|
int flen, res;
|
||||||
|
|
||||||
if (ifname == NULL)
|
if (ifname == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
flen = os_strlen(ctrl_iface_dir) + os_strlen(ifname) + 2;
|
#ifdef ANDROID
|
||||||
cfile = os_malloc(flen);
|
if (access(ctrl_iface_dir, F_OK) < 0) {
|
||||||
if (cfile == NULL)
|
cfile = os_strdup(ifname);
|
||||||
return -1L;
|
if (cfile == NULL)
|
||||||
res = os_snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ifname);
|
return -1;
|
||||||
if (res < 0 || res >= flen) {
|
}
|
||||||
os_free(cfile);
|
#endif /* ANDROID */
|
||||||
return -1;
|
|
||||||
|
if (cfile == NULL) {
|
||||||
|
flen = os_strlen(ctrl_iface_dir) + os_strlen(ifname) + 2;
|
||||||
|
cfile = os_malloc(flen);
|
||||||
|
if (cfile == NULL)
|
||||||
|
return -1;
|
||||||
|
res = os_snprintf(cfile, flen, "%s/%s", ctrl_iface_dir,
|
||||||
|
ifname);
|
||||||
|
if (res < 0 || res >= flen) {
|
||||||
|
os_free(cfile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl_conn = wpa_ctrl_open(cfile);
|
ctrl_conn = wpa_ctrl_open(cfile);
|
||||||
|
@ -3003,8 +3017,17 @@ static char * wpa_cli_get_default_ifname(void)
|
||||||
#ifdef CONFIG_CTRL_IFACE_UNIX
|
#ifdef CONFIG_CTRL_IFACE_UNIX
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
DIR *dir = opendir(ctrl_iface_dir);
|
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 /* ANDROID */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
while ((dent = readdir(dir))) {
|
while ((dent = readdir(dir))) {
|
||||||
#ifdef _DIRENT_HAVE_D_TYPE
|
#ifdef _DIRENT_HAVE_D_TYPE
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue