]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If we don't have a state, send a carrier status
authorRoy Marples <roy@marples.name>
Sat, 16 Feb 2013 17:53:13 +0000 (17:53 +0000)
committerRoy Marples <roy@marples.name>
Sat, 16 Feb 2013 17:53:13 +0000 (17:53 +0000)
script.c

index 863ed29a6ffa1ba4fea2642deac6cf010c76c4bc..867f8c0f029a164ee241bee7c3942f01bfe74051 100644 (file)
--- a/script.c
+++ b/script.c
@@ -464,24 +464,47 @@ send_interface1(int fd, const struct interface *iface, const char *reason)
 int
 send_interface(int fd, const struct interface *iface)
 {
+       const char *reason;
        int retval = 0;
+       int onestate = 0;
 #ifdef INET
        const struct dhcp_state *state = D_CSTATE(iface);
 
-       if (state && send_interface1(fd, iface, state->reason) == -1)
-               retval = -1;
+       if (state) {
+               onestate = 1;
+               if (send_interface1(fd, iface, state->reason) == -1)
+                       retval = -1;
+       }
 #endif
 
 #ifdef INET6
        if (ipv6rs_has_ra(iface)) {
+               onestate = 1;
                if (send_interface1(fd, iface, "ROUTERADVERT") == -1)
                        retval = -1;
        }
        if (D6_STATE_RUNNING(iface)) {
+               onestate = 1;
                if (send_interface1(fd, iface, "INFORM6") == -1)
                        retval = -1;
        }
 #endif
+
+       if (!onestate) {
+               switch (iface->carrier) {
+               case LINK_UP:
+                       reason = "CARRIER";
+                       break;
+               case LINK_DOWN:
+                       reason = "NOCARRIER";
+                       break;
+               default:
+                       reason = "UNKNOWN";
+                       break;
+               }
+               if (send_interface1(fd, iface, reason) == -1)
+                       retval = -1;
+       }
        return retval;
 }