]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
eloop: define eloop queue numbers in common.h
authorRoy Marples <roy@marples.name>
Thu, 6 Feb 2020 12:50:31 +0000 (12:50 +0000)
committerRoy Marples <roy@marples.name>
Thu, 6 Feb 2020 12:50:31 +0000 (12:50 +0000)
Allows for easier maintainance.

src/arp.c
src/common.h
src/dhcp.c
src/dhcp6.c
src/dhcpcd.c
src/eloop.h
src/ipv4ll.c
src/ipv6.c
src/ipv6nd.c

index cd9ac4b5a523d16053828d1be2543ce06722f329..270a22f01695c3f0558b8537591306f545e9e231 100644 (file)
--- a/src/arp.c
+++ b/src/arp.c
@@ -41,7 +41,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#define ELOOP_QUEUE 5
+#define ELOOP_QUEUE    ELOOP_ARP
 #include "config.h"
 #include "arp.h"
 #include "bpf.h"
index 49ff36f91e50fd5794ab3693a8905320e1986592..b054d58197ff8a18df9132e2b0fb07793c2c8efd 100644 (file)
 #include <stdint.h>
 #include <stdio.h>
 
+/* Define eloop queues here, as other apps share eloop.h */
+#define        ELOOP_DHCPCD            1 /* default queue */
+#define        ELOOP_DHCP              2
+#define        ELOOP_ARP               3
+#define        ELOOP_IPV4LL            4
+#define        ELOOP_IPV6              5
+#define        ELOOP_IPV6ND            6
+#define        ELOOP_IPV6RA_EXPIRE     7
+#define        ELOOP_DHCP6             8
+
 #ifndef HOSTNAME_MAX_LEN
 #define HOSTNAME_MAX_LEN       250     /* 255 - 3 (FQDN) - 2 (DNS enc) */
 #endif
index 25081f20a29547f3d7273f4503527901db6220fc..f4a0c63ebec3d140f238d0e7199819890feee793 100644 (file)
@@ -57,7 +57,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#define ELOOP_QUEUE 2
+#define ELOOP_QUEUE    ELOOP_DHCP
 #include "config.h"
 #include "arp.h"
 #include "bpf.h"
index 72170921e6440d0a80d3558a7089af23ea17483c..7012c16468ad4441036d1c3a9ad72fc96e9bfc91 100644 (file)
@@ -45,7 +45,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#define ELOOP_QUEUE 4
+#define ELOOP_QUEUE    ELOOP_DHCP6
 #include "config.h"
 #include "common.h"
 #include "dhcp.h"
index a82af288b55913dbeb86cdfdd0d9d540e036b6f3..3da529829c53c0da45587989d2285e5e7805fdb2 100644 (file)
@@ -400,7 +400,7 @@ stop_interface(struct interface *ifp)
                script_runreason(ifp, "STOPPED");
 
        /* Delete all timeouts for the interfaces */
-       eloop_q_timeout_delete(ctx->eloop, 0, NULL, ifp);
+       eloop_q_timeout_delete(ctx->eloop, ELOOP_QUEUE_ALL, NULL, ifp);
 
        /* De-activate the interface */
        ifp->active = IF_INACTIVE;
index c4942131414bf4277a253b7f6382026f87353f2d..e5d881a1670d97e908e3108ebab56d6155196830 100644 (file)
@@ -46,6 +46,9 @@
   #define ELOOP_QUEUE 1
 #endif
 
+/* Used for deleting a timeout for all queues. */
+#define        ELOOP_QUEUE_ALL 0
+
 /* Forward declare eloop - the content should be invisible to the outside */
 struct eloop;
 
index faf6fbc66d4fd56d58999d9cdb7b2607fb2d8f30..5832703d1d734ccc8c0dc49da9c74d4121cef339 100644 (file)
@@ -36,7 +36,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#define ELOOP_QUEUE 6
+#define ELOOP_QUEUE    IPV4LL
 #include "config.h"
 #include "arp.h"
 #include "common.h"
index 92403912a807025c1bc37ab59a13b2a80b536fbb..216f0c703983df24b5ad486e40feb905d0111c81 100644 (file)
@@ -59,7 +59,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#define ELOOP_QUEUE 7
+#define ELOOP_QUEUE    ELOOP_IPV6
 #include "common.h"
 #include "if.h"
 #include "dhcpcd.h"
@@ -927,7 +927,7 @@ ipv6_doaddr(struct ipv6_addr *ia, struct timespec *now)
                if (ia->flags & IPV6_AF_ADDED)
                        ipv6_deleteaddr(ia);
                eloop_q_timeout_delete(ia->iface->ctx->eloop,
-                   0, NULL, ia);
+                   ELOOP_QUEUE_ALL, NULL, ia);
                if (ia->flags & IPV6_AF_REQUEST) {
                        ia->flags &= ~IPV6_AF_ADDED;
                        return 0;
@@ -969,6 +969,7 @@ ipv6_addaddrs(struct ipv6_addrhead *iaddrs)
 void
 ipv6_freeaddr(struct ipv6_addr *ia)
 {
+       struct eloop *eloop = ia->iface->ctx->eloop;
 #ifndef SMALL
        struct ipv6_addr *iad;
 
@@ -984,10 +985,10 @@ ipv6_freeaddr(struct ipv6_addr *ia)
 
        if (ia->dhcp6_fd != -1) {
                close(ia->dhcp6_fd);
-               eloop_event_delete(ia->iface->ctx->eloop, ia->dhcp6_fd);
+               eloop_event_delete(eloop, ia->dhcp6_fd);
        }
 
-       eloop_q_timeout_delete(ia->iface->ctx->eloop, 0, NULL, ia);
+       eloop_q_timeout_delete(eloop, ELOOP_QUEUE_ALL, NULL, ia);
        free(ia->na);
        free(ia);
 }
index 5a9f8364881bdaf93645cf90738469c98a864a4b..9457545e821f84939c389e1ca547603f00f8e0a0 100644 (file)
@@ -43,7 +43,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#define ELOOP_QUEUE 3
+#define ELOOP_QUEUE    ELOOP_IPV6ND
 #include "common.h"
 #include "dhcpcd.h"
 #include "dhcp-common.h"