mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-04 13:48:30 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52a1ae72f0 | ||
|
|
3a654c506f | ||
|
|
2763d4b51a | ||
|
|
e28836bf45 |
+29
-25
@@ -42,7 +42,7 @@ static void *opt6_find (void *opts, void *end, unsigned int search, unsigned int
|
||||
static void *opt6_next(void *opts, void *end);
|
||||
static unsigned int opt6_uint(unsigned char *opt, int offset, int size);
|
||||
static void get_context_tag(struct state *state, struct dhcp_context *context);
|
||||
static void *check_ia(struct state *state, void *opt, void **endp);
|
||||
static int check_ia(struct state *state, void *opt, void **endp, void **ia_option);
|
||||
static int build_ia(struct state *state, int *t1cntr);
|
||||
static void end_ia(int t1cntr, unsigned int min_time, int do_fuzz);
|
||||
static void add_address(struct state *state, struct dhcp_context *context, unsigned int lease_time, unsigned int requested_time,
|
||||
@@ -511,6 +511,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
if (ignore)
|
||||
return 0;
|
||||
|
||||
/* reset USED bits in leases */
|
||||
lease6_reset();
|
||||
|
||||
for (opt = state.packet_options; opt; opt = opt6_next(opt, state.end))
|
||||
{
|
||||
void *ia_option, *ia_end;
|
||||
@@ -523,7 +526,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
struct in6_addr *req_addr;
|
||||
struct in6_addr addr;
|
||||
|
||||
if (!(ia_option = check_ia(&state, opt, &ia_end)))
|
||||
if (!check_ia(&state, opt, &ia_end, &ia_option))
|
||||
continue;
|
||||
|
||||
if (have_config(config, CONFIG_ADDR6))
|
||||
@@ -539,8 +542,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
config_ok = 0; /* configured address leased elsewhere */
|
||||
}
|
||||
|
||||
/* reset USED bits in leases */
|
||||
lease6_reset();
|
||||
/* reset USED bits in contexts - one address per prefix per IAID */
|
||||
for (c = context; c; c = c->current)
|
||||
c->flags &= ~CONTEXT_USED;
|
||||
|
||||
o = build_ia(&state, &t1cntr);
|
||||
|
||||
@@ -550,10 +554,6 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
ltmp = lease6_find_by_addr(req_addr, 128, 0);
|
||||
requested_time = opt6_uint(ia_option, 16, 4);
|
||||
|
||||
/* reset USED bits in contexts - one address per prefix per IAID */
|
||||
for (c = context; c; c = c->current)
|
||||
c->flags &= ~CONTEXT_USED;
|
||||
|
||||
if ((c = address6_valid(context, req_addr, tagif)))
|
||||
{
|
||||
lease_time = c->lease_time;
|
||||
@@ -608,7 +608,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
}
|
||||
|
||||
/* Return addresses for all valid contexts which don't yet have one */
|
||||
while ((c = address6_allocate(c, state.clid, state.clid_len, state.iaid, tagif, &addr)))
|
||||
while ((c = address6_allocate(context, state.clid, state.clid_len, state.iaid, tagif, &addr)))
|
||||
{
|
||||
add_address(&state, c, c->lease_time, c->lease_time, &min_time, &addr, rapid_commit != NULL, now);
|
||||
get_context_tag(&state, c);
|
||||
@@ -631,6 +631,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
o = new_opt6(OPTION6_PREFERENCE);
|
||||
put_opt6_char(option_bool(OPT_AUTHORITATIVE) ? 255 : 0);
|
||||
end_opt6(o);
|
||||
tagif = add_options(&state, fallback, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -639,9 +640,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
put_opt6_short(DHCP6NOADDRS);
|
||||
put_opt6_string("No addresses available");
|
||||
end_opt6(o1);
|
||||
log6_packet(&state, "DHCPADVERTISE", NULL, _("No addresses available"));
|
||||
}
|
||||
|
||||
tagif = add_options(&state, fallback, context);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -663,8 +664,8 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
unsigned int min_time = 0xffffffff;
|
||||
int t1cntr;
|
||||
|
||||
if (!(ia_option = check_ia(&state, opt, &ia_end)))
|
||||
continue;
|
||||
if (!check_ia(&state, opt, &ia_end, &ia_option))
|
||||
continue;
|
||||
|
||||
o = build_ia(&state, &t1cntr);
|
||||
|
||||
@@ -739,6 +740,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
put_opt6_short(DHCP6NOADDRS);
|
||||
put_opt6_string("No addresses available");
|
||||
end_opt6(o1);
|
||||
log6_packet(&state, "DHCPREPLY", NULL, _("No addresses available"));
|
||||
}
|
||||
|
||||
tagif = add_options(&state, fallback, context);
|
||||
@@ -759,7 +761,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
unsigned int min_time = 0xffffffff;
|
||||
int t1cntr, iacntr;
|
||||
|
||||
if (!(ia_option = check_ia(&state, opt, &ia_end)))
|
||||
if (!check_ia(&state, opt, &ia_end, &ia_option))
|
||||
continue;
|
||||
|
||||
o = build_ia(&state, &t1cntr);
|
||||
@@ -798,8 +800,8 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
}
|
||||
|
||||
|
||||
if ((this_context != address6_available(context, req_addr, tagif)) ||
|
||||
(this_context != address6_valid(context, req_addr, tagif)))
|
||||
if ((this_context = address6_available(context, req_addr, tagif)) ||
|
||||
(this_context = address6_valid(context, req_addr, tagif)))
|
||||
{
|
||||
get_context_tag(&state, this_context);
|
||||
|
||||
@@ -853,7 +855,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
{
|
||||
void *ia_option, *ia_end;
|
||||
|
||||
for (ia_option = check_ia(&state, opt, &ia_end);
|
||||
for (check_ia(&state, opt, &ia_end, &ia_option);
|
||||
ia_option;
|
||||
ia_option = opt6_find(opt6_next(ia_option, ia_end), ia_end, OPTION6_IAADDR, 24))
|
||||
{
|
||||
@@ -909,7 +911,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
void *ia_option, *ia_end;
|
||||
int made_ia = 0;
|
||||
|
||||
for (ia_option = check_ia(&state, opt, &ia_end);
|
||||
for (check_ia(&state, opt, &ia_end, &ia_option);
|
||||
ia_option;
|
||||
ia_option = opt6_find(opt6_next(ia_option, ia_end), ia_end, OPTION6_IAADDR, 24))
|
||||
{
|
||||
@@ -971,7 +973,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
void *ia_option, *ia_end;
|
||||
int made_ia = 0;
|
||||
|
||||
for (ia_option = check_ia(&state, opt, &ia_end);
|
||||
for (check_ia(&state, opt, &ia_end, &ia_option);
|
||||
ia_option;
|
||||
ia_option = opt6_find(opt6_next(ia_option, ia_end), ia_end, OPTION6_IAADDR, 24))
|
||||
{
|
||||
@@ -1044,7 +1046,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
||||
|
||||
struct dhcp_netid *add_options(struct state *state, struct in6_addr *fallback, struct dhcp_context *context)
|
||||
{
|
||||
void *opt, *oro;
|
||||
void *oro;
|
||||
/* filter options based on tags, those we want get DHOPT_TAGOK bit set */
|
||||
struct dhcp_netid *tagif = option_filter(state->tags, state->context_tags, daemon->dhcp_opts6);
|
||||
struct dhcp_opt *opt_cfg;
|
||||
@@ -1255,23 +1257,25 @@ static void get_context_tag(struct state *state, struct dhcp_context *context)
|
||||
}
|
||||
}
|
||||
}
|
||||
static void *check_ia(struct state *state, void *opt, void **endp)
|
||||
static int check_ia(struct state *state, void *opt, void **endp, void **ia_option)
|
||||
{
|
||||
state->ia_type = opt6_type(opt);
|
||||
*ia_option = NULL;
|
||||
|
||||
if (state->ia_type != OPTION6_IA_NA && state->ia_type != OPTION6_IA_TA)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
if (state->ia_type == OPTION6_IA_NA && opt6_len(opt) < 12)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
if (state->ia_type == OPTION6_IA_TA && opt6_len(opt) < 4)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
*endp = opt6_ptr(opt, opt6_len(opt));
|
||||
state->iaid = opt6_uint(opt, 0, 4);
|
||||
|
||||
return opt6_find(opt6_ptr(opt, state->ia_type == OPTION6_IA_NA ? 12 : 4), *endp, OPTION6_IAADDR, 24);
|
||||
*ia_option = opt6_find(opt6_ptr(opt, state->ia_type == OPTION6_IA_NA ? 12 : 4), *endp, OPTION6_IAADDR, 24);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user