[PATCH 2/2] Add Android socket support for wpa_supplicant part

Dmitry Shmidt dimitrysh
Thu Feb 24 15:57:51 PST 2011


Signed-off-by: Dmitry Shmidt <dimitrysh at google.com>
---
 wpa_supplicant/ctrl_iface_unix.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
index 6040828..77578ee 100644
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -17,6 +17,9 @@
 #include <sys/stat.h>
 #include <grp.h>
 #include <stddef.h>
+#ifdef ANDROID
+#include <cutils/sockets.h>
+#endif

 #include "utils/common.h"
 #include "utils/eloop.h"
@@ -276,6 +279,13 @@ wpa_supplicant_ctrl_iface_init(struct
wpa_supplicant *wpa_s)
 	buf = os_strdup(wpa_s->conf->ctrl_interface);
 	if (buf == NULL)
 		goto fail;
+#ifdef ANDROID
+	os_snprintf(addr.sun_path, sizeof(addr.sun_path), "wpa_%s",
+			wpa_s->conf->ctrl_interface);
+	priv->sock = android_get_control_socket(addr.sun_path);
+	if (priv->sock >= 0)
+		goto havesock;
+#endif
 	if (os_strncmp(buf, "DIR=", 4) == 0) {
 		dir = buf + 4;
 		gid_str = os_strstr(dir, " GROUP=");
@@ -398,6 +408,7 @@ wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
 	}
 	os_free(fname);

+havesock:
 	eloop_register_read_sock(priv->sock, wpa_supplicant_ctrl_iface_receive,
 				 wpa_s, priv);
 	wpa_msg_register_cb(wpa_supplicant_ctrl_iface_msg_cb);
@@ -637,6 +648,12 @@ wpa_supplicant_global_ctrl_iface_init(struct
wpa_global *global)
 	if (global->params.ctrl_interface == NULL)
 		return priv;

+#ifdef ANDROID
+	priv->sock = android_get_control_socket(global->params.ctrl_interface);
+	if (priv->sock >= 0)
+		goto havesock;
+#endif
+
 	wpa_printf(MSG_DEBUG, "Global control interface '%s'",
 		   global->params.ctrl_interface);

@@ -685,6 +702,7 @@ wpa_supplicant_global_ctrl_iface_init(struct
wpa_global *global)
 		}
 	}

+havesock:
 	eloop_register_read_sock(priv->sock,
 				 wpa_supplicant_global_ctrl_iface_receive,
 				 global, NULL);
-- 
1.7.3.1



More information about the Hostap mailing list