Turn "used" member of struct iname into flags in preparation for more.

This commit is contained in:
Simon Kelley committed 2023-04-12 16:25:49 +01:00
1 parent 15dcdc824a
commit 597378cdf5
5 files changed
+22 -11

No files matched your search

+1 -1
View File
@@ -553,7 +553,7 @@ char *whichdevice(void)
return NULL; return NULL;
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) 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; return NULL;
for (found = NULL, iface = daemon->interfaces; iface; iface = iface->next) for (found = NULL, iface = daemon->interfaces; iface; iface = iface->next)
+2 -2
View File
@@ -379,7 +379,7 @@ int main (int argc, char **argv)
if (!option_bool(OPT_CLEVERBIND)) if (!option_bool(OPT_CLEVERBIND))
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) 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); die(_("unknown interface %s"), if_tmp->name, EC_BADNET);
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP) #if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP)
@@ -935,7 +935,7 @@ int main (int argc, char **argv)
if (!option_bool(OPT_NOWILD)) if (!option_bool(OPT_NOWILD))
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) 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); my_syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name);
if (daemon->port != 0 && option_bool(OPT_NO_RESOLV)) if (daemon->port != 0 && option_bool(OPT_NO_RESOLV))
+3 -1
View File
@@ -664,10 +664,12 @@ struct listener {
struct iname { struct iname {
char *name; char *name;
union mysockaddr addr; union mysockaddr addr;
int used; int flags;
struct iname *next; struct iname *next;
}; };
#define INAME_USED 1
struct rrlist { struct rrlist {
unsigned short rr; unsigned short rr;
struct rrlist *next; struct rrlist *next;
+14 -5
View File
@@ -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) for (tmp = daemon->if_names; tmp; tmp = tmp->next)
if (tmp->name && wildcard_match(tmp->name, name)) if (tmp->name && wildcard_match(tmp->name, name))
ret = tmp->used = 1; {
tmp->flags |= INAME_USED;
ret = 1;
}
if (addr) if (addr)
for (tmp = daemon->if_addrs; tmp; tmp = tmp->next) 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 && if (family == AF_INET &&
tmp->addr.in.sin_addr.s_addr == addr->addr4.s_addr) 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 && else if (family == AF_INET6 &&
IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr,
&addr->addr6)) &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))) if ((lo->name = whine_malloc(strlen(ifr.ifr_name)+1)))
{ {
strcpy(lo->name, ifr.ifr_name); strcpy(lo->name, ifr.ifr_name);
lo->used = 1; lo->flags |= INAME_USED;
lo->next = daemon->if_names; lo->next = daemon->if_names;
daemon->if_names = lo; daemon->if_names = lo;
} }
@@ -1198,7 +1207,7 @@ void create_bound_listeners(int dienow)
(no netmask) and some MTU login the tftp code. */ (no netmask) and some MTU login the tftp code. */
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next) 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 = create_listeners(&if_tmp->addr, !!option_bool(OPT_TFTP), dienow)))
{ {
new->next = daemon->listeners; new->next = daemon->listeners;
+2 -2
View File
@@ -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 /* new->name may be NULL if someone does
"interface=" to disable all interfaces except loop. */ "interface=" to disable all interfaces except loop. */
new->name = opt_string_alloc(arg); new->name = opt_string_alloc(arg);
new->used = 0; new->flags = 0;
arg = comma; arg = comma;
} while (arg); } while (arg);
break; break;
@@ -2943,7 +2943,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
else else
ret_err_free(gen_err, new); ret_err_free(gen_err, new);
new->used = 0; new->flags = 0;
if (option == 'a') if (option == 'a')
{ {
new->next = daemon->if_addrs; new->next = daemon->if_addrs;