Hi Marcel:
Below patch can be used to partly resolve bug 
750(https://bugzilla.moblin.org/show_bug.cgi?id=750)
On open system, STA can associate to AP without any authentication. So when key 
is changed at AP side, it still can be associated but dhclient will fail. Below 
patch will disconnect the network(release dhclient and disassociate AP) when 
dhclient failed.
So user/UI can know that the AP can not be connected. He can reset the 
passphase or connect to other network.
Any comments are welcome.

To the other case,
When the encryption mode is changed, I think it should be the new network, so 
the old network will not be selected, that can be used to resolve the 
encryption mode change case. I think it should involve with the profile work, I 
will work on it later. 


diff --git a/include/network.h b/include/network.h
index 78e5c0e..15409bd 100644
--- a/include/network.h
+++ b/include/network.h
@@ -80,6 +80,8 @@ extern connman_bool_t connman_network_get_remember(struct 
connman_network *netwo
 
 extern int connman_network_connect(struct connman_network *network);
 
+extern int connman_network_disconnect(struct connman_network *network);
+
 extern int connman_network_set_string(struct connman_network *network,
                                        const char *key, const char *value);
 extern const char *connman_network_get_string(struct connman_network *network,
diff --git a/plugins/dhclient.c b/plugins/dhclient.c
index 7e5e6d0..3790960 100644
--- a/plugins/dhclient.c
+++ b/plugins/dhclient.c
@@ -44,6 +44,7 @@ struct dhclient_task {
        GPid pid;
        int ifindex;
        gchar *ifname;
+       struct connman_network *network;
        struct connman_element *element;
 };
 
@@ -147,6 +148,7 @@ static int dhclient_probe(struct connman_element *element)
        task->ifindex = element->index;
        task->ifname = inet_index2name(element->index);
        task->element = element;
+       task->network = element->parent->network;
 
        if (task->ifname == NULL) {
                g_free(task);
@@ -306,7 +308,8 @@ static DBusHandlerResult dhclient_filter(DBusConnection 
*conn,
        } else if (g_ascii_strcasecmp(text, "RENEW") == 0 ||
                                g_ascii_strcasecmp(text, "REBIND") == 0) {
                connman_element_update(task->element);
-       } else {
+       }else if (g_ascii_strcasecmp(text, "FAIL") == 0) {
+               connman_network_disconnect(task->network);
        }
 
        return DBUS_HANDLER_RESULT_HANDLED;
diff --git a/src/network.c b/src/network.c
index 8cda558..104177e 100644
--- a/src/network.c
+++ b/src/network.c
@@ -825,6 +825,24 @@ int __connman_network_disconnect(struct connman_network 
*network)
        return 0;
 }
 
+int connman_network_disconnect(struct connman_network *network)
+{
+       DBG("network %x", network);
+       if (network->connected == FALSE)
+               return -ENOTCONN;
+
+       connman_element_unregister_children(&network->element);
+
+       connman_device_set_disconnected(network->device, TRUE);
+
+       if (network->driver && network->driver->disconnect)
+               return network->driver->disconnect(network);
+       
+       network->connected = FALSE;
+       
+       return 0; 
+}
+
 /**
  * connman_network_set_string:
  * @network: network structure

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

Reply via email to