Disconnect before re-configuring as this triggers a reassociation if already connected.
authorRoy Marples <roy@marples.name>
Mon, 1 Dec 2014 14:39:18 +0000 (14:39 +0000)
committerRoy Marples <roy@marples.name>
Mon, 1 Dec 2014 14:39:18 +0000 (14:39 +0000)
src/dhcpcd-gtk/wpa.c
src/dhcpcd-qt/dhcpcd-wi.cpp
src/libdhcpcd/dhcpcd.h
src/libdhcpcd/wpa.c

index d8f633b9b9c9689cb4713ca0780c8af7bd64d219..7548824d34077b32627fe7c2505a6be4e12e20fa 100644 (file)
@@ -72,6 +72,12 @@ wpa_conf(DHCPCD_WPA *wpa, DHCPCD_WI_SCAN *scan, const char *psk)
        switch (dhcpcd_wpa_configure_psk(wpa, scan, psk)) {
        case DHCPCD_WPA_SUCCESS:
                return true;
+       case DHCPCD_WPA_ERR_DISCONN:
+               errt = _("Failed to disconnect.");
+               break;
+       case DHCPCD_WPA_ERR_RECONF:
+               errt = _("Faile to reconfigure.");
+               break;
        case DHCPCD_WPA_ERR_SET:
                errt = _("Failed to set key management.");
                break;
index 4b58d4b954017b25d506775404d96edd2a119553..d8bab853144502b53a709d28347a8f1b621eb271 100644 (file)
@@ -247,6 +247,12 @@ void DhcpcdWi::connectSsid(DHCPCD_WI_SCAN *scan)
        switch (dhcpcd_wpa_configure_psk(wpa, &s, psk)) {
        case DHCPCD_WPA_SUCCESS:
                return;
+       case DHCPCD_WPA_ERR_DISCONN:
+               errt = tr("Failed to disconnect.");
+               break;
+       case DHCPCD_WPA_ERR_RECONF:
+               errt = tr("Faile to reconfigure.");
+               break;
        case DHCPCD_WPA_ERR_SET:
                errt = tr("Failed to set key management.");
                break;
index 5e8207b7dc951c8225b938555a5375fbe583176b..4de494d531d0b602f25660de1c1c7ef9728bf168 100644 (file)
@@ -263,6 +263,8 @@ bool dhcpcd_wpa_network_set(DHCPCD_WPA *, int, const char *, const char *);
 #define DHCPCD_WPA_ERR_WRITE   -5
 #define DHCPCD_WPA_ERR_SELECT  -6
 #define DHCPCD_WPA_ERR_ASSOC   -7
+#define DHCPCD_WPA_ERR_DISCONN -8
+#define DHCPCD_WPA_ERR_RECONF  -9
 int dhcpcd_wpa_configure_psk(DHCPCD_WPA *w, DHCPCD_WI_SCAN *s, const char *p);
 
 char ** dhcpcd_config_blocks(DHCPCD_CONNECTION *, const char *);
index 2146d4593a23362e5c3c105f177e01acef92162f..8e2bae587517d2356e286cec4a279480baa22d64 100644 (file)
@@ -1035,10 +1035,13 @@ dhcpcd_wpa_configure_psk(DHCPCD_WPA *wpa, DHCPCD_WI_SCAN *s, const char *psk)
        assert(wpa);
        assert(s);
 
+       if (!dhcpcd_wpa_disconnect(wpa))
+               return DHCPCD_WPA_ERR_DISCONN;
+
        /* reload the configuration so that when we don't save
         * the disabled networks to the config file. */
        if (!dhcpcd_wpa_reconfigure(wpa))
-               return DHCPCD_WPA_ERR;
+               return DHCPCD_WPA_ERR_RECONF;
 
        id = dhcpcd_wpa_network_find_new(wpa, s->ssid);
        if (id == -1)