aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/wpa_ctrl.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-05-18 08:42:09 (GMT)
committerJouni Malinen <j@w1.fi>2013-05-18 08:42:09 (GMT)
commitd2a9e2c76dfbce64c13b502bcdfd1ab1510b8b4a (patch)
treec6eaefbce24a6c39ef19fc68e5f86c0c5b8e2b94 /src/common/wpa_ctrl.c
parent6fd5ceaf70ad32effea675c5f7dc0c76fc19cc23 (diff)
downloadhostap-d2a9e2c76dfbce64c13b502bcdfd1ab1510b8b4a.zip
hostap-d2a9e2c76dfbce64c13b502bcdfd1ab1510b8b4a.tar.gz
hostap-d2a9e2c76dfbce64c13b502bcdfd1ab1510b8b4a.tar.bz2
Abstract and Android sockets for global ctrl_iface
The wpa_supplicant global control interface parameter can now be used to explicitly specify an abstract UNIX domain socket (Linux specific extension) with "@abstract:" prefix and an Android control socket with "@android:" prefix. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/common/wpa_ctrl.c')
-rw-r--r--src/common/wpa_ctrl.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
index 58cbe6a..d9a7509 100644
--- a/src/common/wpa_ctrl.c
+++ b/src/common/wpa_ctrl.c
@@ -82,6 +82,9 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
int tries = 0;
int flags;
+ if (ctrl_path == NULL)
+ return NULL;
+
ctrl = os_malloc(sizeof(*ctrl));
if (ctrl == NULL)
return NULL;
@@ -126,13 +129,27 @@ try_again:
#ifdef ANDROID
chmod(ctrl->local.sun_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
chown(ctrl->local.sun_path, AID_SYSTEM, AID_WIFI);
+
+ if (os_strncmp(ctrl_path, "@android:", 9) == 0) {
+ if (socket_local_client_connect(
+ ctrl->s, ctrl_path + 9,
+ ANDROID_SOCKET_NAMESPACE_RESERVED,
+ SOCK_DGRAM) < 0) {
+ close(ctrl->s);
+ unlink(ctrl->local.sun_path);
+ os_free(ctrl);
+ return NULL;
+ }
+ return ctrl;
+ }
+
/*
* If the ctrl_path isn't an absolute pathname, assume that
* it's the name of a socket in the Android reserved namespace.
* Otherwise, it's a normal UNIX domain socket appearing in the
* filesystem.
*/
- if (ctrl_path != NULL && *ctrl_path != '/') {
+ if (*ctrl_path != '/') {
char buf[21];
os_snprintf(buf, sizeof(buf), "wpa_%s", ctrl_path);
if (socket_local_client_connect(
@@ -149,12 +166,18 @@ try_again:
#endif /* ANDROID */
ctrl->dest.sun_family = AF_UNIX;
- res = os_strlcpy(ctrl->dest.sun_path, ctrl_path,
- sizeof(ctrl->dest.sun_path));
- if (res >= sizeof(ctrl->dest.sun_path)) {
- close(ctrl->s);
- os_free(ctrl);
- return NULL;
+ if (os_strncmp(ctrl_path, "@abstract:", 10) == 0) {
+ ctrl->dest.sun_path[0] = '\0';
+ os_strlcpy(ctrl->dest.sun_path + 1, ctrl_path + 10,
+ sizeof(ctrl->dest.sun_path) - 1);
+ } else {
+ res = os_strlcpy(ctrl->dest.sun_path, ctrl_path,
+ sizeof(ctrl->dest.sun_path));
+ if (res >= sizeof(ctrl->dest.sun_path)) {
+ close(ctrl->s);
+ os_free(ctrl);
+ return NULL;
+ }
}
if (connect(ctrl->s, (struct sockaddr *) &ctrl->dest,
sizeof(ctrl->dest)) < 0) {