From 153f9c1cd9a5b749f57e28682fadb39c781e1e5d Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 24 Mar 2008 19:46:53 +0000 Subject: Import of WPA supplicant 0.5.10 --- contrib/wpa_supplicant/ctrl_iface_unix.c | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'contrib/wpa_supplicant/ctrl_iface_unix.c') diff --git a/contrib/wpa_supplicant/ctrl_iface_unix.c b/contrib/wpa_supplicant/ctrl_iface_unix.c index e9bc472..9e4f85f 100644 --- a/contrib/wpa_supplicant/ctrl_iface_unix.c +++ b/contrib/wpa_supplicant/ctrl_iface_unix.c @@ -522,9 +522,42 @@ static void wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv) { - wpa_printf(MSG_DEBUG, "CTRL_IFACE - %s - wait for monitor", - priv->wpa_s->ifname); - eloop_wait_for_read_sock(priv->sock); + char buf[256]; + int res; + struct sockaddr_un from; + socklen_t fromlen = sizeof(from); + + for (;;) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE - %s - wait for monitor to " + "attach", priv->wpa_s->ifname); + eloop_wait_for_read_sock(priv->sock); + + res = recvfrom(priv->sock, buf, sizeof(buf) - 1, 0, + (struct sockaddr *) &from, &fromlen); + if (res < 0) { + perror("recvfrom(ctrl_iface)"); + continue; + } + buf[res] = '\0'; + + if (os_strcmp(buf, "ATTACH") == 0) { + /* handle ATTACH signal of first monitor interface */ + if (!wpa_supplicant_ctrl_iface_attach(priv, &from, + fromlen)) { + sendto(priv->sock, "OK\n", 3, 0, + (struct sockaddr *) &from, fromlen); + /* OK to continue */ + return; + } else { + sendto(priv->sock, "FAIL\n", 5, 0, + (struct sockaddr *) &from, fromlen); + } + } else { + /* return FAIL for all other signals */ + sendto(priv->sock, "FAIL\n", 5, 0, + (struct sockaddr *) &from, fromlen); + } + } } -- cgit v1.1