mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Remove experimental DHCPv6 prefix-class support.
The standard for this never made it beyond an internet-draft which expired in 2012, so it can be considered dead, I think.
This commit is contained in:
152
src/rfc3315.c
152
src/rfc3315.c
@@ -31,9 +31,6 @@ struct state {
|
||||
struct dhcp_netid *tags, *context_tags;
|
||||
unsigned char mac[DHCP_CHADDR_MAX];
|
||||
unsigned int mac_len, mac_type;
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
struct prefix_class *send_prefix_class;
|
||||
#endif
|
||||
};
|
||||
|
||||
static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz,
|
||||
@@ -49,9 +46,6 @@ static void get_context_tag(struct state *state, struct dhcp_context *context);
|
||||
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);
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
static struct prefix_class *prefix_class_from_context(struct dhcp_context *context);
|
||||
#endif
|
||||
static void mark_context_used(struct state *state, struct in6_addr *addr);
|
||||
static void mark_config_used(struct dhcp_context *context, struct in6_addr *addr);
|
||||
static int check_address(struct state *state, struct in6_addr *addr);
|
||||
@@ -276,10 +270,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
struct dhcp_context *context_tmp;
|
||||
struct dhcp_mac *mac_opt;
|
||||
unsigned int ignore = 0;
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
struct prefix_class *p;
|
||||
int dump_all_prefix_classes = 0;
|
||||
#endif
|
||||
|
||||
state->packet_options = inbuff + 4;
|
||||
state->end = inbuff + sz;
|
||||
@@ -293,9 +283,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
state->hostname = NULL;
|
||||
state->client_hostname = NULL;
|
||||
state->fqdn_flags = 0x01; /* default to send if we receive no FQDN option */
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
state->send_prefix_class = NULL;
|
||||
#endif
|
||||
|
||||
/* set tag with name == interface */
|
||||
iface_id.net = state->iface_name;
|
||||
@@ -590,31 +577,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
state->tags = &known_id;
|
||||
}
|
||||
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
/* OPTION_PREFIX_CLASS in ORO, send addresses in all prefix classes */
|
||||
if (daemon->prefix_classes && (msg_type == DHCP6SOLICIT || msg_type == DHCP6REQUEST))
|
||||
{
|
||||
void *oro;
|
||||
|
||||
if ((oro = opt6_find(state->packet_options, state->end, OPTION6_ORO, 0)))
|
||||
for (i = 0; i < opt6_len(oro) - 1; i += 2)
|
||||
if (opt6_uint(oro, i, 2) == OPTION6_PREFIX_CLASS)
|
||||
{
|
||||
dump_all_prefix_classes = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg_type != DHCP6SOLICIT || dump_all_prefix_classes)
|
||||
/* Add the tags associated with prefix classes so we can use the DHCP ranges.
|
||||
Not done for SOLICIT as we add them one-at-time. */
|
||||
for (p = daemon->prefix_classes; p ; p = p->next)
|
||||
{
|
||||
p->tag.next = state->tags;
|
||||
state->tags = &p->tag;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
tagif = run_tag_if(state->tags);
|
||||
|
||||
/* if all the netids in the ignore list are present, ignore this client */
|
||||
@@ -698,60 +660,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
for (c = state->context; c; c = c->current)
|
||||
c->flags &= ~CONTEXT_USED;
|
||||
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (daemon->prefix_classes && state->ia_type == OPTION6_IA_NA)
|
||||
{
|
||||
void *prefix_opt;
|
||||
int prefix_class;
|
||||
|
||||
if (dump_all_prefix_classes)
|
||||
/* OPTION_PREFIX_CLASS in ORO, send addresses in all prefix classes */
|
||||
plain_range = 0;
|
||||
else
|
||||
{
|
||||
if ((prefix_opt = opt6_find(opt6_ptr(opt, 12), ia_end, OPTION6_PREFIX_CLASS, 2)))
|
||||
{
|
||||
|
||||
prefix_class = opt6_uint(prefix_opt, 0, 2);
|
||||
|
||||
for (p = daemon->prefix_classes; p ; p = p->next)
|
||||
if (p->class == prefix_class)
|
||||
break;
|
||||
|
||||
if (!p)
|
||||
my_syslog(MS_DHCP | LOG_WARNING, _("unknown prefix-class %d"), prefix_class);
|
||||
else
|
||||
{
|
||||
/* add tag to list, and exclude undecorated dhcp-ranges */
|
||||
p->tag.next = state->tags;
|
||||
solicit_tags = run_tag_if(&p->tag);
|
||||
plain_range = 0;
|
||||
state->send_prefix_class = p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* client didn't ask for a prefix class, lets see if we can find one. */
|
||||
for (p = daemon->prefix_classes; p ; p = p->next)
|
||||
{
|
||||
p->tag.next = NULL;
|
||||
if (match_netid(&p->tag, solicit_tags, 1))
|
||||
break;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
plain_range = 0;
|
||||
state->send_prefix_class = p;
|
||||
}
|
||||
}
|
||||
|
||||
if (p && option_bool(OPT_LOG_OPTS))
|
||||
my_syslog(MS_DHCP | LOG_INFO, "%u prefix class %d tag:%s", state->xid, p->class, p->tag.net);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
o = build_ia(state, &t1cntr);
|
||||
if (address_assigned)
|
||||
address_assigned = 2;
|
||||
@@ -780,10 +688,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
continue; /* address leased elsewhere */
|
||||
|
||||
/* add address to output packet */
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (dump_all_prefix_classes && state->ia_type == OPTION6_IA_NA)
|
||||
state->send_prefix_class = prefix_class_from_context(c);
|
||||
#endif
|
||||
add_address(state, c, lease_time, ia_option, &min_time, &req_addr, now);
|
||||
mark_context_used(state, &req_addr);
|
||||
get_context_tag(state, c);
|
||||
@@ -803,11 +707,8 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
lease_time = config->lease_time;
|
||||
else
|
||||
lease_time = c->lease_time;
|
||||
|
||||
/* add address to output packet */
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (dump_all_prefix_classes && state->ia_type == OPTION6_IA_NA)
|
||||
state->send_prefix_class = prefix_class_from_context(c);
|
||||
#endif
|
||||
add_address(state, c, lease_time, NULL, &min_time, &addr, now);
|
||||
mark_context_used(state, &addr);
|
||||
get_context_tag(state, c);
|
||||
@@ -821,10 +722,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
req_addr = ltmp->addr6;
|
||||
if ((c = address6_available(state->context, &req_addr, solicit_tags, plain_range)))
|
||||
{
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (dump_all_prefix_classes && state->ia_type == OPTION6_IA_NA)
|
||||
state->send_prefix_class = prefix_class_from_context(c);
|
||||
#endif
|
||||
add_address(state, c, c->lease_time, NULL, &min_time, &req_addr, now);
|
||||
mark_context_used(state, &req_addr);
|
||||
get_context_tag(state, c);
|
||||
@@ -836,10 +733,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
while ((c = address6_allocate(state->context, state->clid, state->clid_len, state->ia_type == OPTION6_IA_TA,
|
||||
state->iaid, ia_counter, solicit_tags, plain_range, &addr)))
|
||||
{
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (dump_all_prefix_classes && state->ia_type == OPTION6_IA_NA)
|
||||
state->send_prefix_class = prefix_class_from_context(c);
|
||||
#endif
|
||||
add_address(state, c, c->lease_time, NULL, &min_time, &addr, now);
|
||||
mark_context_used(state, &addr);
|
||||
get_context_tag(state, c);
|
||||
@@ -982,10 +875,6 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
||||
if (config_ok && have_config(config, CONFIG_TIME))
|
||||
lease_time = config->lease_time;
|
||||
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (dump_all_prefix_classes && state->ia_type == OPTION6_IA_NA)
|
||||
state->send_prefix_class = prefix_class_from_context(c);
|
||||
#endif
|
||||
add_address(state, dynamic, lease_time, ia_option, &min_time, &req_addr, now);
|
||||
get_context_tag(state, dynamic);
|
||||
address_assigned = 1;
|
||||
@@ -1630,21 +1519,6 @@ static void get_context_tag(struct state *state, struct dhcp_context *context)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
static struct prefix_class *prefix_class_from_context(struct dhcp_context *context)
|
||||
{
|
||||
struct prefix_class *p;
|
||||
struct dhcp_netid *t;
|
||||
|
||||
for (p = daemon->prefix_classes; p ; p = p->next)
|
||||
for (t = context->filter; t; t = t->next)
|
||||
if (strcmp(p->tag.net, t->net) == 0)
|
||||
return p;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int check_ia(struct state *state, void *opt, void **endp, void **ia_option)
|
||||
{
|
||||
state->ia_type = opt6_type(opt);
|
||||
@@ -1729,16 +1603,6 @@ static void add_address(struct state *state, struct dhcp_context *context, unsig
|
||||
put_opt6(addr, sizeof(*addr));
|
||||
put_opt6_long(preferred_time);
|
||||
put_opt6_long(valid_time);
|
||||
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
if (state->send_prefix_class)
|
||||
{
|
||||
int o1 = new_opt6(OPTION6_PREFIX_CLASS);
|
||||
put_opt6_short(state->send_prefix_class->class);
|
||||
end_opt6(o1);
|
||||
}
|
||||
#endif
|
||||
|
||||
end_opt6(o);
|
||||
|
||||
if (state->lease_allocate)
|
||||
@@ -1774,16 +1638,9 @@ static void mark_context_used(struct state *state, struct in6_addr *addr)
|
||||
struct dhcp_context *context;
|
||||
|
||||
/* Mark that we have an address for this prefix. */
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
for (context = state->context; context; context = context->current)
|
||||
if (is_same_net6(addr, &context->start6, context->prefix) &&
|
||||
(!state->send_prefix_class || state->send_prefix_class == prefix_class_from_context(context)))
|
||||
context->flags |= CONTEXT_USED;
|
||||
#else
|
||||
for (context = state->context; context; context = context->current)
|
||||
if (is_same_net6(addr, &context->start6, context->prefix))
|
||||
context->flags |= CONTEXT_USED;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void mark_config_used(struct dhcp_context *context, struct in6_addr *addr)
|
||||
@@ -2010,13 +1867,6 @@ static void log6_opts(int nest, unsigned int xid, void *start_opts, void *end_op
|
||||
optname = "iaaddr";
|
||||
ia_options = opt6_ptr(opt, 24);
|
||||
}
|
||||
#ifdef OPTION6_PREFIX_CLASS
|
||||
else if (type == OPTION6_PREFIX_CLASS)
|
||||
{
|
||||
optname = "prefix-class";
|
||||
sprintf(daemon->namebuff, "class=%u", opt6_uint(opt, 0, 2));
|
||||
}
|
||||
#endif
|
||||
else if (type == OPTION6_STATUS_CODE)
|
||||
{
|
||||
int len = sprintf(daemon->namebuff, "%u ", opt6_uint(opt, 0, 2));
|
||||
|
||||
Reference in New Issue
Block a user