Fix wpa stopping and describe DEPARTED a bit better.
authorRoy Marples <roy@marples.name>
Fri, 12 Sep 2014 13:31:25 +0000 (13:31 +0000)
committerRoy Marples <roy@marples.name>
Fri, 12 Sep 2014 13:31:25 +0000 (13:31 +0000)
src/libdhcpcd/dhcpcd.c
src/libdhcpcd/wpa.c

index 0b817b1a6dc5acd5ae2557736ad028548c9c4d02..4a8823d4d677cbd07514441ec99e1a59a3d6f9b4 100644 (file)
@@ -375,7 +375,7 @@ dhcpcd_new_if(DHCPCD_CONNECTION *con, char *data, size_t len)
         } else if (strcmp(type, "link")) {
                /* If link is down, ignore it */
                e = dhcpcd_get_if(con, ifname, "link");
-               if (e && strcmp(e->reason, "NOCARRIER") == 0)
+               if (e && !e->up)
                        return NULL;
        }
 
@@ -790,7 +790,9 @@ dhcpcd_if_message(DHCPCD_IF *i, bool *new_msg)
                                reason = _("Not associated");
                } else
                        reason = _("Cable unplugged");
-       } else if (strcmp(i->reason, "UNKNOWN") == 0)
+       } else if (strcmp(i->reason, "DEPARTED") == 0)
+               reason = _("Departed");
+       else if (strcmp(i->reason, "UNKNOWN") == 0)
                reason = _("Unknown link state");
        else if (strcmp(i->reason, "FAIL") == 0)
                reason = _("Automatic configuration not possible");
index 354dd4176e3a613f75f83276e7db802f1d97ca2a..4861c5c8fbc893d8bfe00eb3753ac92dddc0a3fc 100644 (file)
@@ -674,12 +674,14 @@ dhcpcd_wpa_if_event(DHCPCD_IF *i)
        DHCPCD_WPA *wpa;
 
        assert(i);
-       if (i->wireless && strcmp(i->type, "link") == 0) {
-               if (strcmp(i->reason, "STOPPED") == 0) {
+       if (strcmp(i->type, "link") == 0) {
+               if (strcmp(i->reason, "STOPPED") == 0 ||
+                   strcmp(i->reason, "DEPARTED") == 0)
+               {
                        wpa = dhcpcd_wpa_find(i->con, i->ifname);
                        if (wpa)
                                dhcpcd_wpa_close(wpa);
-               } else if (i->con->wpa_started) {
+               } else if (i->wireless && i->con->wpa_started) {
                        wpa = dhcpcd_wpa_new(i->con, i->ifname);
                        if (wpa && wpa->listen_fd == -1)
                                dhcpcd_wpa_open(wpa);