[PATCH 4/7] Adding ctrl iface command for autoscan

Tomasz Bursztyka tomasz.bursztyka
Fri Apr 20 04:23:25 PDT 2012


Signed-hostap: Tomasz Bursztyka <tomasz.bursztyka at linux.intel.com>
---
 wpa_supplicant/ctrl_iface.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 5ff6766..8bbb001 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -41,6 +41,7 @@
 #include "interworking.h"
 #include "blacklist.h"
 #include "wpas_glue.h"
+#include "autoscan.h"
 
 extern struct wpa_driver_ops *wpa_drivers[];
 
@@ -3257,6 +3258,34 @@ static int wpa_supplicant_ctrl_iface_sta_autoconnect(
 }
 
 
+#ifdef CONFIG_AUTOSCAN
+
+static int wpa_supplicant_ctrl_iface_autoscan(struct wpa_supplicant *wpa_s,
+					      char *cmd)
+{
+	enum wpa_states state = wpa_s->wpa_state;
+
+	if (wpa_s->conf->autoscan != NULL) {
+		os_free(wpa_s->conf->autoscan);
+		wpa_s->conf->autoscan = NULL;
+	}
+
+	if (cmd != NULL && os_strlen(cmd) > 0) {
+		wpa_s->conf->autoscan = os_strdup(cmd);
+		if (wpa_s->conf->autoscan == NULL)
+			return -1;
+
+		if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
+			autoscan_init(wpa_s);
+	} else if (os_strlen(cmd) == 0)
+		autoscan_deinit(wpa_s);
+
+	return 0;
+}
+
+#endif /* CONFIG_AUTOSCAN */
+
+
 static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf,
 				      size_t buflen)
 {
@@ -3698,6 +3727,11 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
 	} else if (os_strncmp(buf, "SIGNAL_POLL", 11) == 0) {
 		reply_len = wpa_supplicant_signal_poll(wpa_s, reply,
 						       reply_size);
+#ifdef CONFIG_AUTOSCAN
+	} else if (os_strncmp(buf, "AUTOSCAN ", 9) == 0) {
+		if (wpa_supplicant_ctrl_iface_autoscan(wpa_s, buf + 9))
+			reply_len = -1;
+#endif
 	} else {
 		os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
 		reply_len = 16;
-- 
1.7.8.5




More information about the Hostap mailing list