summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hankins <dhankins@isc.org>2007-11-06 18:31:36 +0000
committerDavid Hankins <dhankins@isc.org>2007-11-06 18:31:36 +0000
commit290b43b9cbdb9e53a69c3e0ffab1c5e8c5b55979 (patch)
tree57940a4e78c08e8c8f7f9453485403e9bc9e3be5
parent65cf86d7abff65597f35fc7962908099eca0c856 (diff)
downloadisc-dhcp-290b43b9cbdb9e53a69c3e0ffab1c5e8c5b55979.tar.gz
Remove unreviewed sources from HEAD.
-rw-r--r--RELNOTES4
-rw-r--r--client/clparse.c3
-rw-r--r--common/options.c182
-rw-r--r--includes/dhcpd.h19
-rw-r--r--includes/tree.h2
-rw-r--r--server/dhcpv6.c35
6 files changed, 89 insertions, 156 deletions
diff --git a/RELNOTES b/RELNOTES
index 3d514cbb..4623f606 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -57,10 +57,6 @@ suggested fixes to <dhcp-users@isc.org>.
- Clarified error message when lease limit exceeded
-- The server will now include multiple IA_NA's and multiple IAADDRs within
- them, if advertised by the client. It still only seeks to allocate one
- new address.
-
- Relative time may now be used as a qualifier for 'allow' and 'deny' access
control lists. These directives may be used to assist in re-addressing
address pools without having to constantly reconfigure the server. Please
diff --git a/client/clparse.c b/client/clparse.c
index 6ed59f5e..e52cea6c 100644
--- a/client/clparse.c
+++ b/client/clparse.c
@@ -1177,7 +1177,8 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
case OPTION:
oc = (struct option_cache *)0;
if (parse_option_decl (&oc, cfile)) {
- save_option(oc->option->universe, lease->options, oc);
+ save_option (oc -> option -> universe,
+ lease -> options, oc);
option_cache_dereference (&oc, MDL);
}
return;
diff --git a/common/options.c b/common/options.c
index f310c872..0dd3b594 100644
--- a/common/options.c
+++ b/common/options.c
@@ -43,10 +43,6 @@ static int pretty_text(char **, char *, const unsigned char **,
const unsigned char *, int);
static int pretty_domain(char **, char *, const unsigned char **,
const unsigned char *);
-static int prepare_option_buffer(struct universe *universe, struct buffer *bp,
- unsigned char *buffer, unsigned length,
- unsigned code, int terminatep,
- struct option_cache **opp);
/* Parse all available options out of the specified packet. */
@@ -2147,64 +2143,15 @@ struct option_cache *lookup_hashed_option (universe, options, code)
return (struct option_cache *)0;
}
-/* Save a specified buffer into an option cache. */
-int
-save_option_buffer(struct universe *universe, struct option_state *options,
- struct buffer *bp, unsigned char *buffer, unsigned length,
- unsigned code, int terminatep)
-{
- struct option_cache *op = NULL;
- int status = 1;
-
- status = prepare_option_buffer(universe, bp, buffer, length, code,
- terminatep, &op);
-
- if (status == 0)
- goto cleanup;
-
- save_option(universe, options, op);
-
- cleanup:
- if (op != NULL)
- option_cache_dereference(&op, MDL);
-
- return status;
-}
-
-/* Append a specified buffer onto the tail of an option cache. */
-int
-append_option_buffer(struct universe *universe, struct option_state *options,
- struct buffer *bp, unsigned char *buffer, unsigned length,
- unsigned code, int terminatep)
-{
- struct option_cache *op = NULL;
- int status = 1;
-
- status = prepare_option_buffer(universe, bp, buffer, length, code,
- terminatep, &op);
-
- if (status == 0)
- goto cleanup;
-
- also_save_option(universe, options, op);
-
- cleanup:
- if (op != NULL)
- option_cache_dereference(&op, MDL);
-
- return status;
-}
-
-/* Create/copy a buffer into a new option cache. */
-static int
-prepare_option_buffer(struct universe *universe, struct buffer *bp,
- unsigned char *buffer, unsigned length, unsigned code,
- int terminatep, struct option_cache **opp)
+int save_option_buffer (struct universe *universe,
+ struct option_state *options,
+ struct buffer *bp,
+ unsigned char *buffer, unsigned length,
+ unsigned code, int tp)
{
- struct buffer *lbp = NULL;
+ struct buffer *lbp = (struct buffer *)0;
+ struct option_cache *op = (struct option_cache *)0;
struct option *option = NULL;
- struct option_cache *op;
- int status = 1;
/* Code sizes of 8, 16, and 32 bits are allowed. */
switch(universe->tag_size) {
@@ -2252,28 +2199,26 @@ prepare_option_buffer(struct universe *universe, struct buffer *bp,
option->refcnt = 1;
}
- if (!option_cache_allocate (opp, MDL)) {
+ if (!option_cache_allocate (&op, MDL)) {
log_error("No memory for option code %s.%s.",
universe->name, option->name);
- status = 0;
- goto cleanup;
+ option_dereference(&option, MDL);
+ return 0;
}
- /* Pointer rather than double pointer makes for less parens. */
- op = *opp;
-
option_reference(&op->option, option, MDL);
/* If we weren't passed a buffer in which the data are saved and
refcounted, allocate one now. */
if (!bp) {
- if (!buffer_allocate (&lbp, length + terminatep, MDL)) {
+ if (!buffer_allocate (&lbp, length + tp, MDL)) {
log_error ("no memory for option buffer.");
- status = 0;
- goto cleanup;
+ option_cache_dereference (&op, MDL);
+ option_dereference(&option, MDL);
+ return 0;
}
- memcpy (lbp -> data, buffer, length + terminatep);
+ memcpy (lbp -> data, buffer, length + tp);
bp = lbp;
buffer = &bp -> data [0]; /* Refer to saved buffer. */
}
@@ -2286,7 +2231,7 @@ prepare_option_buffer(struct universe *universe, struct buffer *bp,
op -> data.data = buffer;
op -> data.len = length;
- if (terminatep) {
+ if (tp) {
/* NUL terminate (we can get away with this because we (or
the caller!) allocated one more than the buffer size, and
because the byte following the end of an option is always
@@ -2312,8 +2257,11 @@ prepare_option_buffer(struct universe *universe, struct buffer *bp,
}
}
+ /* Now store the option. */
+ save_option (universe, options, op);
+
/* And let go of our references. */
- cleanup:
+ option_cache_dereference (&op, MDL);
option_dereference(&option, MDL);
return 1;
@@ -2350,10 +2298,6 @@ collect_oro(struct option_cache *oc,
oro->len += 2;
}
-/* build_server_oro() is presently unusued, but may be used at a future date
- * with support for Reconfigure messages (as a hint to the client about new
- * option value contents).
- */
void
build_server_oro(struct data_string *server_oro,
struct option_state *options,
@@ -2418,31 +2362,20 @@ build_server_oro(struct data_string *server_oro,
}
}
-/* Wrapper function to put an option cache into an option state. */
-void
-save_option(struct universe *universe, struct option_state *options,
- struct option_cache *oc)
-{
- if (universe->save_func)
- (*universe->save_func)(universe, options, oc, ISC_FALSE);
- else
- log_error("can't store options in %s space.", universe->name);
-}
-
-/* Wrapper function to append an option cache into an option state's list. */
-void
-also_save_option(struct universe *universe, struct option_state *options,
- struct option_cache *oc)
+void save_option (struct universe *universe,
+ struct option_state *options, struct option_cache *oc)
{
- if (universe->save_func)
- (*universe->save_func)(universe, options, oc, ISC_TRUE);
+ if (universe -> save_func)
+ (*universe -> save_func) (universe, options, oc);
else
- log_error("can't store options in %s space.", universe->name);
+ log_error ("can't store options in %s space.",
+ universe -> name);
}
-void
-save_hashed_option(struct universe *universe, struct option_state *options,
- struct option_cache *oc, isc_boolean_t appendp)
+void save_hashed_option (universe, options, oc)
+ struct universe *universe;
+ struct option_state *options;
+ struct option_cache *oc;
{
int hashix;
pair bptr;
@@ -2474,22 +2407,12 @@ save_hashed_option(struct universe *universe, struct option_state *options,
break;
}
- /* Deal with collisions on the hash list. */
+ /* If we find one, dereference it and put the new one
+ in its place. */
if (bptr) {
ocloc = (struct option_cache **)&bptr->car;
- /*
- * If appendp is set, append it onto the tail of the
- * ->next list. If it is not set, rotate it into
- * position at the head of the list.
- */
- if (appendp) {
- while ((*ocloc)->next != NULL)
- ocloc = &(*ocloc)->next;
- } else {
- option_cache_dereference(ocloc, MDL);
- }
-
+ option_cache_dereference(ocloc, MDL);
option_cache_reference(ocloc, oc, MDL);
return;
}
@@ -3130,35 +3053,44 @@ int fqdn_option_space_encapsulate (result, packet, lease, client_state,
return status;
}
-/*
- * Trap invalid attempts to inspect FQND6 contents.
+/* Shill to the DHCPv4 fqdn option cache any lookups in the fqdn6 universe.
+ *
+ * XXX: Is this necessary? There shouldn't be any lookups directly...
*/
struct option_cache *
lookup_fqdn6_option(struct universe *universe, struct option_state *options,
unsigned code)
{
log_fatal("Impossible condition at %s:%d.", MDL);
- return NULL;
+
+ return fqdn_universe.lookup_func(&fqdn_universe, options, code);
}
-/*
- * Trap invalid attempts to save options directly to FQDN6 rather than FQDN.
+/* Shill to the DHCPv4 fqdn option cache any direct saves to the fqdn6
+ * universe.
+ *
+ * XXX: Should this even be possible? Never excercised code?
*/
void
save_fqdn6_option(struct universe *universe, struct option_state *options,
- struct option_cache *oc, isc_boolean_t appendp)
+ struct option_cache *oc)
{
log_fatal("Impossible condition at %s:%d.", MDL);
+
+ fqdn_universe.save_func(&fqdn_universe, options, oc);
}
-/*
- * Trap invalid attempts to delete an option out of the FQDN6 universe.
+/* Shill to the DHCPv4 fqdn option cache any attempts to remove entries.
+ *
+ * XXX: Again...should this even be possible?
*/
void
delete_fqdn6_option(struct universe *universe, struct option_state *options,
int code)
{
log_fatal("Impossible condition at %s:%d.", MDL);
+
+ fqdn_universe.delete_func(&fqdn_universe, options, code);
}
/* Shill to the DHCPv4 fqdn option cache any attempts to traverse the
@@ -3463,9 +3395,10 @@ void hashed_option_space_foreach (struct packet *packet, struct lease *lease,
}
}
-void
-save_linked_option(struct universe *universe, struct option_state *options,
- struct option_cache *oc, isc_boolean_t appendp)
+void save_linked_option (universe, options, oc)
+ struct universe *universe;
+ struct option_state *options;
+ struct option_cache *oc;
{
pair *tail;
struct option_chain_head *head;
@@ -3489,12 +3422,7 @@ save_linked_option(struct universe *universe, struct option_state *options,
ocloc = (struct option_cache **)&(*tail)->car;
if (oc->option->code == (*ocloc)->option->code) {
- if (appendp) {
- while ((*ocloc)->next != NULL)
- ocloc = &(*ocloc)->next;
- } else {
- option_cache_dereference(ocloc, MDL);
- }
+ option_cache_dereference(ocloc, MDL);
option_cache_reference(ocloc, oc, MDL);
return;
}
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index 0d5de798..6b614590 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -1387,7 +1387,7 @@ lookup_fqdn6_option(struct universe *universe, struct option_state *options,
unsigned code);
void
save_fqdn6_option(struct universe *universe, struct option_state *options,
- struct option_cache *oc, isc_boolean_t appendp);
+ struct option_cache *oc);
void
delete_fqdn6_option(struct universe *universe, struct option_state *options,
int code);
@@ -1457,17 +1457,12 @@ struct option_cache *next_hashed_option(struct universe *,
int save_option_buffer (struct universe *, struct option_state *,
struct buffer *, unsigned char *, unsigned,
unsigned, int);
-int append_option_buffer(struct universe *, struct option_state *,
- struct buffer *, unsigned char *, unsigned,
- unsigned, int);
void build_server_oro(struct data_string *, struct option_state *,
const char *, int);
-void save_option(struct universe *, struct option_state *,
- struct option_cache *);
-void also_save_option(struct universe *, struct option_state *,
- struct option_cache *);
-void save_hashed_option(struct universe *, struct option_state *,
- struct option_cache *, isc_boolean_t appendp);
+void save_option PROTO ((struct universe *,
+ struct option_state *, struct option_cache *));
+void save_hashed_option PROTO ((struct universe *,
+ struct option_state *, struct option_cache *));
void delete_option PROTO ((struct universe *, struct option_state *, int));
void delete_hashed_option PROTO ((struct universe *,
struct option_state *, int));
@@ -1554,8 +1549,8 @@ int linked_option_get PROTO ((struct data_string *, struct universe *,
int linked_option_state_dereference PROTO ((struct universe *,
struct option_state *,
const char *, int));
-void save_linked_option(struct universe *, struct option_state *,
- struct option_cache *, isc_boolean_t appendp);
+void save_linked_option (struct universe *, struct option_state *,
+ struct option_cache *);
void linked_option_space_foreach (struct packet *, struct lease *,
struct client_state *,
struct option_state *,
diff --git a/includes/tree.h b/includes/tree.h
index 8171ce1b..8ce66c4b 100644
--- a/includes/tree.h
+++ b/includes/tree.h
@@ -304,7 +304,7 @@ struct universe {
struct option_state *,
unsigned);
void (*save_func) (struct universe *, struct option_state *,
- struct option_cache *, isc_boolean_t);
+ struct option_cache *);
void (*foreach) (struct packet *,
struct lease *, struct client_state *,
struct option_state *, struct option_state *,
diff --git a/server/dhcpv6.c b/server/dhcpv6.c
index cb4b26e5..ac6a9492 100644
--- a/server/dhcpv6.c
+++ b/server/dhcpv6.c
@@ -756,6 +756,7 @@ start_reply(struct packet *packet,
struct dhcpv6_packet *reply)
{
struct option_cache *oc;
+ struct data_string server_oro;
const unsigned char *server_id_data;
int server_id_len;
@@ -876,6 +877,21 @@ start_reply(struct packet *packet,
}
}
+ /*
+ * Set the ORO for the main packet.
+ */
+ build_server_oro(&server_oro, *opt_state, MDL);
+ if (!save_option_buffer(&dhcpv6_universe, *opt_state,
+ server_oro.buffer,
+ (unsigned char *)server_oro.data,
+ server_oro.len, D6O_ORO, 0)) {
+ log_error("start_reply: error saving server ORO.");
+ data_string_forget(&server_oro, MDL);
+ option_state_dereference(opt_state, MDL);
+ return 0;
+ }
+ data_string_forget(&server_oro, MDL);
+
return 1;
}
@@ -1935,14 +1951,11 @@ reply_process_is_addressed(struct reply_state *reply,
reply->valid = reply->send_valid;
#if 0
- /*
- * XXX: Old 4.0.0 alpha code would change the host {} record
- * XXX: uid upon lease assignment. This was intended to cover the
- * XXX: case where a client first identifies itself using vendor
- * XXX: options in a solicit, or request, but later neglects to include
- * XXX: these options in a Renew or Rebind. It is not clear that this
- * XXX: is required, and has some startling ramnifications (such as
- * XXX: how to recover this dynamic host {} state across restarts).
+ /* XXX: Old 4.0.0 alpha code would change the host {} record
+ * XXX: uid upon lease assignment. I think this was an error;
+ * XXX: it doesn't make sense to me now in retrospect to change
+ * XXX: what is essentially configuration state with network
+ * XXX: supplied values.
*/
if (reply->host != NULL)
change_host_uid(host, reply->client_id->data,
@@ -2008,9 +2021,9 @@ reply_process_send_addr(struct reply_state *reply, struct iaddr *addr) {
putULong(data.buffer->data + 16, reply->send_prefer);
putULong(data.buffer->data + 20, reply->send_valid);
- if (!append_option_buffer(&dhcpv6_universe, reply->reply_ia,
- data.buffer, data.buffer->data,
- data.len, D6O_IAADDR, 0)) {
+ if (!save_option_buffer(&dhcpv6_universe, reply->reply_ia,
+ data.buffer, data.buffer->data,
+ data.len, D6O_IAADDR, 0)) {
log_error("reply_process_ia: unable to save IAADDR "
"option");
status = ISC_R_FAILURE;