aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorYotam Rubin <yotam@wizery.com>2011-12-25 15:39:38 +0200
committerArik Nemtsov <arik@wizery.com>2012-08-02 13:03:59 +0300
commit5e44dd8ec1c606d9547a7f33b4f4b5196091dc02 (patch)
treef52643adb696021031006156719f08f7b4e4c577 /hostapd
parent7bccfbe37385b49cfab7535d3f0fb008b8d2efaf (diff)
downloadexternal_wpa_supplicant_8_ti-5e44dd8ec1c606d9547a7f33b4f4b5196091dc02.zip
external_wpa_supplicant_8_ti-5e44dd8ec1c606d9547a7f33b4f4b5196091dc02.tar.gz
external_wpa_supplicant_8_ti-5e44dd8ec1c606d9547a7f33b4f4b5196091dc02.tar.bz2
hostapd: add support for android created sockets (/dev/socket/)
Add the same support that wpa_supplicant has with sockets created by the Android system using the init.rc services options Just as the supplicant, if the ctrl_iface is a name and not a path (i.e. doesn't start with '/') the hostapd will assume that this is an Android created socket named wpa_$(ctrl_iface) which is opened in /dev/socket/ hostapd_cli sockets will be created in /data/misc/wifi/sockets The hardcoded configuration is set in the Android.mk of hostapd just like it is with the supplicant. In addition, the hostapd_cli needs an Android property by the name ap.interface to hold the ctrl_iface name to connect to the hostapd's socket.
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/Android.mk3
-rw-r--r--hostapd/ctrl_iface.c14
-rw-r--r--hostapd/hostapd_cli.c37
3 files changed, 48 insertions, 6 deletions
diff --git a/hostapd/Android.mk b/hostapd/Android.mk
index 8858b7c..e6f431c 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -28,6 +28,9 @@ ifeq ($(BOARD_WLAN_DEVICE), bcmdhd)
L_CFLAGS += -DANDROID_BRCM_P2P_PATCH
endif
+# Use Android specific directory for control interface sockets
+L_CFLAGS += -DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/data/misc/wifi/sockets\"
+
# To force sizeof(enum) = 4
ifeq ($(TARGET_ARCH),arm)
L_CFLAGS += -mabi=aapcs-linux
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 7587e03..8f42f90 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -13,6 +13,9 @@
#include <sys/un.h>
#include <sys/stat.h>
#include <stddef.h>
+#ifdef ANDROID
+#include <cutils/sockets.h>
+#endif /* ANDROID */
#include "utils/common.h"
#include "utils/eloop.h"
@@ -957,6 +960,14 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
if (hapd->conf->ctrl_interface == NULL)
return 0;
+#ifdef ANDROID
+ os_snprintf(addr.sun_path, sizeof(addr.sun_path), "wpa_%s",
+ hapd->conf->ctrl_interface);
+ s = android_get_control_socket(addr.sun_path);
+ if (s >= 0)
+ goto havesock;
+#endif /* ANDROID */
+
if (mkdir(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
if (errno == EEXIST) {
wpa_printf(MSG_DEBUG, "Using existing control "
@@ -1037,6 +1048,9 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
}
os_free(fname);
+#ifdef ANDROID
+havesock:
+#endif /* ANDROID */
hapd->ctrl_sock = s;
eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
NULL);
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index 0c33d5b..f3fba3e 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -14,6 +14,9 @@
#include "utils/eloop.h"
#include "utils/edit.h"
#include "common/version.h"
+#ifdef ANDROID
+#include <cutils/properties.h>
+#endif /* ANDROID */
static const char *hostapd_cli_version =
@@ -128,17 +131,27 @@ static void usage(void)
static struct wpa_ctrl * hostapd_cli_open_connection(const char *ifname)
{
- char *cfile;
+ char *cfile = NULL;
int flen;
if (ifname == NULL)
return NULL;
- flen = strlen(ctrl_iface_dir) + strlen(ifname) + 2;
- cfile = malloc(flen);
- if (cfile == NULL)
- return NULL;
- snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ifname);
+#ifdef ANDROID
+ if (access(ctrl_iface_dir, F_OK) < 0) {
+ cfile = os_strdup(ifname);
+ if (cfile == NULL)
+ return NULL;
+ }
+#endif /* ANDROID */
+
+ if (cfile == NULL) {
+ flen = strlen(ctrl_iface_dir) + strlen(ifname) + 2;
+ cfile = malloc(flen);
+ if (cfile == NULL)
+ return NULL;
+ snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ifname);
+ }
ctrl_conn = wpa_ctrl_open(cfile);
free(cfile);
@@ -1103,6 +1116,18 @@ int main(int argc, char *argv[])
}
closedir(dir);
}
+#ifdef ANDROID
+ else {
+ char ifprop[PROPERTY_VALUE_MAX];
+ int res = property_get("ap.interface", ifprop,
+ NULL);
+ if (!res) {
+ ctrl_ifname = os_strdup(ifprop);
+ printf("Using interface '%s'\n",
+ ctrl_ifname);
+ }
+ }
+#endif /* ANDROID */
}
ctrl_conn = hostapd_cli_open_connection(ctrl_ifname);
if (ctrl_conn) {