Remove ability to compile without IPv6 support.

This was the source of a large number of #ifdefs, originally
included for use with old embedded libc versions. I'm
sure no-one wants or needs IPv6-free code these days, so this
is a move towards more maintainable code.
This commit is contained in:
Simon Kelley
2018-10-23 22:10:17 +01:00
parent a220545c42
commit ee8750451b
22 changed files with 56 additions and 418 deletions

View File

@@ -764,10 +764,8 @@ static char *parse_mysockaddr(char *arg, union mysockaddr *addr)
{
if (inet_pton(AF_INET, arg, &addr->in.sin_addr) > 0)
addr->sa.sa_family = AF_INET;
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, &addr->in6.sin6_addr) > 0)
addr->sa.sa_family = AF_INET6;
#endif
else
return _("bad address");
@@ -779,10 +777,8 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
int source_port = 0, serv_port = NAMESERVER_PORT;
char *portno, *source;
char *interface_opt = NULL;
#ifdef HAVE_IPV6
int scope_index = 0;
char *scope_id;
#endif
if (!arg || strlen(arg) == 0)
{
@@ -800,9 +796,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
!atoi_check16(portno, &serv_port))
return _("bad port");
#ifdef HAVE_IPV6
scope_id = split_chr(arg, '%');
#endif
if (source) {
interface_opt = split_chr(source, '@');
@@ -846,7 +840,6 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
}
}
}
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, &addr->in6.sin6_addr) > 0)
{
if (scope_id && (scope_index = if_nametoindex(scope_id)) == 0)
@@ -881,7 +874,6 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
}
}
}
#endif
else
return _("bad address");
@@ -1914,10 +1906,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
unhide_metas(arg);
if (inet_pton(AF_INET, arg, &new->addr.in.sin_addr) > 0)
new->addr.sa.sa_family = AF_INET;
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, &new->addr.in6.sin6_addr) > 0)
new->addr.sa.sa_family = AF_INET6;
#endif
else
{
char *fam = split_chr(arg, '/');
@@ -1927,10 +1917,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
{
if (strcmp(fam, "4") == 0)
new->addr.sa.sa_family = AF_INET;
#ifdef HAVE_IPV6
else if (strcmp(fam, "6") == 0)
new->addr.sa.sa_family = AF_INET6;
#endif
else
ret_err(gen_err);
}
@@ -1996,14 +1984,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
subnet->prefixlen = (prefixlen == 0) ? 24 : prefixlen;
subnet->flags = ADDRLIST_LITERAL;
}
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, &addr.addr.addr6))
{
subnet = opt_malloc(sizeof(struct addrlist));
subnet->prefixlen = (prefixlen == 0) ? 64 : prefixlen;
subnet->flags = ADDRLIST_LITERAL | ADDRLIST_IPV6;
}
#endif
else
{
struct auth_name_list *name = opt_malloc(sizeof(struct auth_name_list));
@@ -2015,10 +2001,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
{
if (prefixlen == 4)
name->flags &= ~AUTH6;
#ifdef HAVE_IPV6
else if (prefixlen == 6)
name->flags &= ~AUTH4;
#endif
else
ret_err(gen_err);
}
@@ -2139,7 +2123,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
}
}
}
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, comma, &new->start6))
{
u64 mask = (1LLU << (128 - msize)) - 1LLU;
@@ -2183,7 +2166,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
}
}
}
#endif
else
ret_err(gen_err);
}
@@ -2201,7 +2183,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
else if (!inet_pton(AF_INET, arg, &new->end))
ret_err(gen_err);
}
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, comma, &new->start6))
{
new->is6 = 1;
@@ -2210,7 +2191,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
else if (!inet_pton(AF_INET6, arg, &new->end6))
ret_err(gen_err);
}
#endif
else
ret_err(gen_err);
@@ -2369,7 +2349,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
new->addr.in.sin_len = sizeof(new->addr.in);
#endif
}
#ifdef HAVE_IPV6
else if (arg && inet_pton(AF_INET6, arg, &new->addr.in6.sin6_addr) > 0)
{
new->addr.sa.sa_family = AF_INET6;
@@ -2380,7 +2359,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
new->addr.in6.sin6_len = sizeof(new->addr.in6);
#endif
}
#endif
else
ret_err(gen_err);
@@ -2493,9 +2471,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
int size;
struct server *serv;
struct in_addr addr4;
#ifdef HAVE_IPV6
struct in6_addr addr6;
#endif
unhide_metas(arg);
if (!arg || !(comma=split(arg)) || !(string = split_chr(arg, '/')) || !atoi_check(string, &size))
@@ -2507,10 +2483,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
if (!serv)
ret_err(_("bad prefix"));
}
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, &addr6))
serv = add_rev6(&addr6, size);
#endif
else
ret_err(gen_err);
@@ -3863,10 +3837,8 @@ err:
{
if (strcmp(arg, "4") == 0)
new->family = AF_INET;
#ifdef HAVE_IPV6
else if (strcmp(arg, "6") == 0)
new->family = AF_INET6;
#endif
else
ret_err(gen_err);
}
@@ -4156,10 +4128,8 @@ err:
new->ttl = atoi(arg);
else if (inet_pton(AF_INET, arg, &addr))
new->addr = addr.addr.addr4;
#ifdef HAVE_IPV6
else if (inet_pton(AF_INET6, arg, &addr))
new->addr6 = addr.addr.addr6;
#endif
else
{
int nomem;
@@ -4866,10 +4836,8 @@ void read_opts(int argc, char **argv, char *compile_opts)
{
if (tmp->source_addr.sa.sa_family == AF_INET)
tmp->source_addr.in.sin_port = htons(daemon->query_port);
#ifdef HAVE_IPV6
else if (tmp->source_addr.sa.sa_family == AF_INET6)
tmp->source_addr.in6.sin6_port = htons(daemon->query_port);
#endif
}
}
@@ -4930,10 +4898,8 @@ void read_opts(int argc, char **argv, char *compile_opts)
for(tmp = daemon->if_addrs; tmp; tmp = tmp->next)
if (tmp->addr.sa.sa_family == AF_INET)
tmp->addr.in.sin_port = htons(daemon->port);
#ifdef HAVE_IPV6
else if (tmp->addr.sa.sa_family == AF_INET6)
tmp->addr.in6.sin6_port = htons(daemon->port);
#endif /* IPv6 */
}
/* create default, if not specified */