From: Jaehyun Kim <[email protected]>

Unable to connect with the WEP mode AP again with correct passphrase
if connecting the AP with wrong passphrase before.

Because the WEP has not 4way-handshake, ConnMan can't receive
the error message of the invalid key, and can't set
the passphrase to NULL when connection failed with wrong passphrase.
---
 plugins/wifi.c | 16 ++++++++++++++++
 src/service.c  |  4 +++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 533d6df..58bcff2 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1416,6 +1416,7 @@ static void disconnect_callback(int result, 
GSupplicantInterface *interface,
 static int network_disconnect(struct connman_network *network)
 {
        struct connman_device *device = connman_network_get_device(network);
+       struct connman_service *service;
        struct wifi_data *wifi;
        int err;
 
@@ -1425,6 +1426,21 @@ static int network_disconnect(struct connman_network 
*network)
        if (!wifi || !wifi->interface)
                return -ENODEV;
 
+       if (connman_network_get_associating(network) == TRUE)
+               connman_network_set_error(network,
+                                       CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
+       else {
+               service = connman_service_lookup_from_network(network);
+
+               if (service != NULL &&
+                       (__connman_service_is_connected_state(service,
+                               CONNMAN_IPCONFIG_TYPE_IPV4) == FALSE &&
+                       __connman_service_is_connected_state(service,
+                               CONNMAN_IPCONFIG_TYPE_IPV6) == FALSE) &&
+                       (connman_service_get_favorite(service) == FALSE))
+                       __connman_service_set_passphrase(service, NULL);
+       }
+
        connman_network_set_associating(network, false);
 
        if (wifi->disconnecting)
diff --git a/src/service.c b/src/service.c
index 33cce14..6583dbf 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5424,7 +5424,9 @@ int __connman_service_indicate_error(struct 
connman_service *service,
 
        set_error(service, error);
 
-       if (service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY)
+       if (service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY ||
+               (service->favorite == FALSE &&
+               service->error == CONNMAN_SERVICE_ERROR_CONNECT_FAILED))
                __connman_service_set_passphrase(service, NULL);
 
        /*
-- 
1.8.1.2

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to