[PATCH 4/4] wifi: Check invalid key/passphrase in gsupplicant connect callback

patrik.flykt at nokia.com patrik.flykt at nokia.com
Mon Jan 24 04:20:58 PST 2011


From: Patrik Flykt <patrik.flykt at nokia.com>

Use network struct as connect callback user data and set network
error to CONNMAN_NETWORK_ERROR_INVALID_KEY if gsupplicant indicates
key/passphrase error. For other errors < 0 set network error to
CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL.
---
 plugins/wifi.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 040d2f9..7c80c2a 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -576,7 +576,17 @@ static void network_remove(struct connman_network *network)
 static void connect_callback(int result, GSupplicantInterface *interface,
 							void *user_data)
 {
-	connman_error("%s", __func__);
+	struct connman_network *network = user_data;
+
+	DBG("network %p result %d", network, result);
+
+	if (result == -ENOKEY) {
+		connman_network_set_error(network,
+					CONNMAN_NETWORK_ERROR_INVALID_KEY);
+	} else if (result < 0) {
+		connman_network_set_error(network,
+					CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
+	}
 }
 
 static GSupplicantSecurity network_security(const char *security)
@@ -670,7 +680,7 @@ static int network_connect(struct connman_network *network)
 		wifi->network = connman_network_ref(network);
 
 		return g_supplicant_interface_connect(interface, ssid,
-						connect_callback, NULL);
+						connect_callback, network);
 	}
 
 	return -EINPROGRESS;
-- 
1.7.2.3




More information about the connman mailing list