radv.c tidying.

This commit is contained in:
Simon Kelley
2012-03-29 11:07:25 +01:00
parent 0e88d53faa
commit 1e02a85970

View File

@@ -276,7 +276,6 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
static int add_prefixes(struct in6_addr *local, int prefix,
int scope, int if_index, int dad, void *vparam)
{
struct dhcp_context *context;
struct ra_param *param = vparam;
(void)scope; /* warning */
@@ -290,11 +289,11 @@ static int add_prefixes(struct in6_addr *local, int prefix,
!IN6_IS_ADDR_LINKLOCAL(local) &&
!IN6_IS_ADDR_MULTICAST(local))
{
int do_prefix = 0;
int do_slaac = 0;
int deprecate = 0;
unsigned int time = 0xffffffff;
struct in6_addr *addr = NULL;
struct prefix_opt *opt;
struct dhcp_context *context;
for (context = daemon->ra_contexts; context; context = context->next)
if (prefix == context->prefix &&
@@ -331,16 +330,20 @@ static int add_prefixes(struct in6_addr *local, int prefix,
param->first = 0;
param->found_context = 1;
if (context->flags & CONTEXT_RA_DONE)
continue;
if (!(context->flags & CONTEXT_RA_DONE))
{
context->flags |= CONTEXT_RA_DONE;
addr = &context->start6;
do_prefix = 1;
}
}
if (addr && (opt = expand(sizeof(struct prefix_opt))))
if (do_prefix)
{
u64 addrpart = addr6part(addr);
struct prefix_opt *opt;
if ((opt = expand(sizeof(struct prefix_opt))))
{
u64 addrpart = addr6part(local);
u64 mask = (prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU;
/* lifetimes must be min 2 hrs, by RFC 2462 */
@@ -356,7 +359,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
opt->reserved = 0;
opt->prefix = *addr;
opt->prefix = *local;
setaddr6part(&opt->prefix, addrpart & ~mask);
inet_ntop(AF_INET6, &opt->prefix, daemon->addrbuff, ADDRSTRLEN);
@@ -364,6 +367,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
}
}
}
}
return 1;
}