diff mbox

Add state message sent after 'status' command

Message ID 20131111205332.2CA1A13FACD@ushik.mtv.corp.google.com
State Accepted
Headers show

Commit Message

Dmitry Shmidt Nov. 11, 2013, 8:52 p.m. UTC
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
---
 wpa_supplicant/ctrl_iface.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Jouni Malinen Nov. 17, 2013, 4:26 p.m. UTC | #1
I applied this in order to support the current Android framework design.
However, it is quite bad design to make the STATUS command generate an
event message (or well, even worse to generate the CTRL-EVENT-CONNECTED
event since it could result in unintended duplicated operations like
DHCP update on other systems). As such, I would strongly discourage the
use of this mechanism and hope that Android framework moves away from
depending this hack in the future. The proper way to get this type of
information would be to look at the STATUS command return value which
include lot of the information and if anything is missing from there, it
can be added easily.
diff mbox

Patch

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index ebe08b3..820b556 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -1621,6 +1621,25 @@  static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
 	if (res >= 0)
 		pos += res;
 
+#ifdef ANDROID
+	wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
+		     "id=%d state=%d BSSID=" MACSTR " SSID=%s",
+		     wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
+		     wpa_s->wpa_state,
+		     MAC2STR(wpa_s->bssid),
+		     wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
+		     wpa_ssid_txt(wpa_s->current_ssid->ssid,
+		     wpa_s->current_ssid->ssid_len) : "");
+	if (wpa_s->wpa_state == WPA_COMPLETED) {
+		struct wpa_ssid *ssid = wpa_s->current_ssid;
+		wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_CONNECTED "- connection to "
+			MACSTR " completed %s [id=%d id_str=%s]",
+			MAC2STR(wpa_s->bssid), "(auth)",
+			ssid ? ssid->id : -1,
+			ssid && ssid->id_str ? ssid->id_str : "");
+	}
+#endif /* ANDROID */
+
 	return pos - buf;
 }