From 597378cdf55b248a54b930fa31acbad7415aaefd Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Wed, 12 Apr 2023 16:25:49 +0100 Subject: Turn "used" member of struct iname into flags in preparation for more. --- src/dhcp-common.c | 2 +- src/dnsmasq.c | 4 ++-- src/dnsmasq.h | 4 +++- src/network.c | 19 ++++++++++++++----- src/option.c | 4 ++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/dhcp-common.c b/src/dhcp-common.c index 1d96bc6..360cdc5 100644 --- a/src/dhcp-common.c +++ b/src/dhcp-common.c @@ -553,7 +553,7 @@ char *whichdevice(void) return NULL; for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) - if (if_tmp->name && (!if_tmp->used || strchr(if_tmp->name, '*'))) + if (if_tmp->name && (!(if_tmp->flags & INAME_USED) || strchr(if_tmp->name, '*'))) return NULL; for (found = NULL, iface = daemon->interfaces; iface; iface = iface->next) diff --git a/src/dnsmasq.c b/src/dnsmasq.c index c0dd5ac..bc6644c 100644 --- a/src/dnsmasq.c +++ b/src/dnsmasq.c @@ -379,7 +379,7 @@ int main (int argc, char **argv) if (!option_bool(OPT_CLEVERBIND)) for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) - if (if_tmp->name && !if_tmp->used) + if (if_tmp->name && !(if_tmp->flags & INAME_USED)) die(_("unknown interface %s"), if_tmp->name, EC_BADNET); #if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP) @@ -935,7 +935,7 @@ int main (int argc, char **argv) if (!option_bool(OPT_NOWILD)) for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) - if (if_tmp->name && !if_tmp->used) + if (if_tmp->name && !(if_tmp->flags & INAME_USED)) my_syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name); if (daemon->port != 0 && option_bool(OPT_NO_RESOLV)) diff --git a/src/dnsmasq.h b/src/dnsmasq.h index 90919de..2a57969 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -664,10 +664,12 @@ struct listener { struct iname { char *name; union mysockaddr addr; - int used; + int flags; struct iname *next; }; +#define INAME_USED 1 + struct rrlist { unsigned short rr; struct rrlist *next; diff --git a/src/network.c b/src/network.c index 7343d00..9c5c613 100644 --- a/src/network.c +++ b/src/network.c @@ -123,7 +123,10 @@ int iface_check(int family, union all_addr *addr, char *name, int *auth) for (tmp = daemon->if_names; tmp; tmp = tmp->next) if (tmp->name && wildcard_match(tmp->name, name)) - ret = tmp->used = 1; + { + tmp->flags |= INAME_USED; + ret = 1; + } if (addr) for (tmp = daemon->if_addrs; tmp; tmp = tmp->next) @@ -131,11 +134,17 @@ int iface_check(int family, union all_addr *addr, char *name, int *auth) { if (family == AF_INET && tmp->addr.in.sin_addr.s_addr == addr->addr4.s_addr) - ret = match_addr = tmp->used = 1; + { + tmp->flags |= INAME_USED; + ret = match_addr = 1; + } else if (family == AF_INET6 && IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, &addr->addr6)) - ret = match_addr = tmp->used = 1; + { + tmp->flags |= INAME_USED; + ret = match_addr = 1; + } } } @@ -501,7 +510,7 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label, if ((lo->name = whine_malloc(strlen(ifr.ifr_name)+1))) { strcpy(lo->name, ifr.ifr_name); - lo->used = 1; + lo->flags |= INAME_USED; lo->next = daemon->if_names; daemon->if_names = lo; } @@ -1198,7 +1207,7 @@ void create_bound_listeners(int dienow) (no netmask) and some MTU login the tftp code. */ for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next) - if (!if_tmp->used && + if (!(if_tmp->flags & INAME_USED) && (new = create_listeners(&if_tmp->addr, !!option_bool(OPT_TFTP), dienow))) { new->next = daemon->listeners; diff --git a/src/option.c b/src/option.c index 146ca0c..94bc682 100644 --- a/src/option.c +++ b/src/option.c @@ -2833,7 +2833,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma /* new->name may be NULL if someone does "interface=" to disable all interfaces except loop. */ new->name = opt_string_alloc(arg); - new->used = 0; + new->flags = 0; arg = comma; } while (arg); break; @@ -2943,7 +2943,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma else ret_err_free(gen_err, new); - new->used = 0; + new->flags = 0; if (option == 'a') { new->next = daemon->if_addrs; -- cgit v1.2.1