]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix compile on Linux.
authorRoy Marples <roy@marples.name>
Thu, 19 Mar 2009 19:17:34 +0000 (19:17 +0000)
committerRoy Marples <roy@marples.name>
Thu, 19 Mar 2009 19:17:34 +0000 (19:17 +0000)
dhcpcd.c
if-linux.c

index 2448f5e24a6ba2a755fba8825ae6a3b5872e51ba..1805265c4f5dca0123a9091efe395505ac6f0273 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -35,6 +35,10 @@ const char copyright[] = "Copyright (c) 2006-2009 Roy Marples";
 #include <arpa/inet.h>
 #include <net/route.h>
 
+#ifdef __linux__
+#  include <linux/rtnetlink.h>
+#endif
+
 #include <ctype.h>
 #include <errno.h>
 #include <getopt.h>
index 0f4a3ab4fc94dff2f10b2a71a9b15eb389006241..8c9c945cbc2acd20719b49122b5989327179d268 100644 (file)
 
 #define BUFFERLEN 256
 
-static void (*nl_carrier)(const char *);
-static void (*nl_add)(const char *);
-static void (*nl_remove)(const char *);
-
 static int sock_fd;
 static struct sockaddr_nl sock_nl;
 
@@ -253,30 +249,17 @@ link_netlink(struct nlmsghdr *nlm)
                }
                rta = RTA_NEXT(rta, len);
        }
-       if (nlm->nlmsg_type == RTM_NEWLINK) {
-               if (ifi->ifi_change == ~0U) {
-                       if (nl_add)
-                               nl_add(ifn);
-               } else {
-                       if (nl_carrier)
-                               nl_carrier(ifn);
-               }
-       } else {
-               if (nl_remove)
-                       nl_remove(ifn);
-       }
+       if (nlm->nlmsg_type == RTM_NEWLINK)
+               len = ifi->ifi_change == ~0U ? 1 : 0;
+       else
+               len = -1;
+       handle_interface(len, ifn);
        return 1;
 }
 
 int
-manage_link(int fd,
-    void (*if_carrier)(const char *),
-    void (*if_add)(const char *),
-    void (*if_remove)(const char *))
+manage_link(int fd)
 {
-       nl_carrier = if_carrier;
-       nl_add = if_add;
-       nl_remove = if_remove;
        return get_netlink(fd, MSG_DONTWAIT, &link_netlink);
 }