]> 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 13:03:01 +0000 (13:03 +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 15925a8f9b1e61eb91514db9976bd9fac7bfc38a..44422c031c4030aef2bb1406fdf3215d70c9ed05 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 4e8bcdead667a67b1a5ef7fd091d035837996533..b55483d0b68dee0cf6fdf2c9c99f01869ec7d6c9 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 d5cb7305efd371faf7ccf048965b7640989f325b..d111d99a923d31d906c03d073347ff5e45e3ec43 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 df29ace787bbb56596ae3e94e246bc2ea1a8fb63..d1adbbcc6ed877f87bf565d0c343b9879f7a8fd6 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 98e812181b8ce12704ea65fac8b6f1f66ce45803..7d55020ba96053c980a2320d22955c35ab71f16c 100644 (file)
@@ -435,7 +435,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 18cd06d7d60b04c49b21631871a4f81216c35f57..0013043fafa3e69657865f81585688802712b0de 100644 (file)
@@ -67,6 +67,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 42a6a78416a7f9ecef5ce7e1d35eff3117fb1c6f..eb1d6cb17f2771717a6881bc6fa4b3ae9ccac204 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 288f822a9d575f21370dc2b68a9345c8f6177427..9092a6c9519a17ab644511e9cdf26c68e12cb0c6 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"
@@ -932,7 +932,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;
@@ -974,6 +974,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;
 
@@ -989,10 +990,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 55f8c993f0437c5da903731ce85da718ab6b901f..90fdecf4a78163605d0f2aa154fd31c460f99bb6 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"