wifi: Check invalid key/passphrase in gsupplicant connect callback
authorPatrik Flykt <patrik.flykt@nokia.com>
Fri, 4 Feb 2011 13:14:22 +0000 (15:14 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 8 Feb 2011 00:02:44 +0000 (01:02 +0100)
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

index c4089c0..78da6ac 100644 (file)
@@ -329,7 +329,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)
@@ -428,7 +438,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;