Mercurial > hg > dhcpcd
changeset 5038:1e35e845790a draft
eloop: define eloop queue numbers in common.h
Allows for easier maintainance.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 06 Feb 2020 12:50:31 +0000 |
| parents | 52dd608e14b5 |
| children | c44b319ae036 |
| files | 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 |
| diffstat | 9 files changed, 24 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/arp.c Wed Feb 05 15:35:44 2020 +0000 +++ b/src/arp.c Thu Feb 06 12:50:31 2020 +0000 @@ -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"
--- a/src/common.h Wed Feb 05 15:35:44 2020 +0000 +++ b/src/common.h Thu Feb 06 12:50:31 2020 +0000 @@ -34,6 +34,16 @@ #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
--- a/src/dhcp.c Wed Feb 05 15:35:44 2020 +0000 +++ b/src/dhcp.c Thu Feb 06 12:50:31 2020 +0000 @@ -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"
--- a/src/dhcp6.c Wed Feb 05 15:35:44 2020 +0000 +++ b/src/dhcp6.c Thu Feb 06 12:50:31 2020 +0000 @@ -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"
--- a/src/dhcpcd.c Wed Feb 05 15:35:44 2020 +0000 +++ b/src/dhcpcd.c Thu Feb 06 12:50:31 2020 +0000 @@ -400,7 +400,7 @@ 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;
--- a/src/eloop.h Wed Feb 05 15:35:44 2020 +0000 +++ b/src/eloop.h Thu Feb 06 12:50:31 2020 +0000 @@ -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;
--- a/src/ipv4ll.c Wed Feb 05 15:35:44 2020 +0000 +++ b/src/ipv4ll.c Thu Feb 06 12:50:31 2020 +0000 @@ -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"
--- a/src/ipv6.c Wed Feb 05 15:35:44 2020 +0000 +++ b/src/ipv6.c Thu Feb 06 12:50:31 2020 +0000 @@ -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 @@ 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 @@ void ipv6_freeaddr(struct ipv6_addr *ia) { + struct eloop *eloop = ia->iface->ctx->eloop; #ifndef SMALL struct ipv6_addr *iad; @@ -984,10 +985,10 @@ 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); }
