{
const char *val;
enum dhcp_token token;
- struct class *class = (struct class *)0, *pc = (struct class *)0;
+ struct class *class = NULL, *pc = NULL;
int declaration = 0;
int lose = 0;
struct data_string data;
char *name;
const char *tname;
- struct executable_statement *stmt = (struct executable_statement *)0;
+ struct executable_statement *stmt = NULL;
int new = 1;
isc_result_t status = ISC_R_FAILURE;
int matchedonce = 0;
"for DHCPv6.");
}
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token (&val, NULL, cfile);
if (token != STRING) {
parse_warn (cfile, "Expecting class name");
skip_to_semi (cfile);
the vendor class or user class. */
if ((type == CLASS_TYPE_VENDOR) || (type == CLASS_TYPE_USER)) {
data.len = strlen (val);
- data.buffer = (struct buffer *)0;
+ data.buffer = NULL;
if (!buffer_allocate (&data.buffer, data.len + 1, MDL))
log_fatal ("no memory for class name.");
data.data = &data.buffer -> data [0];
} else if (type == CLASS_TYPE_CLASS) {
tname = val;
} else {
- tname = (const char *)0;
+ tname = NULL;
}
if (tname) {
log_fatal ("No memory for class name %s.", tname);
strcpy (name, val);
} else
- name = (char *)0;
+ name = NULL;
/* If this is a straight subclass, parse the hash string. */
if (type == CLASS_TYPE_SUBCLASS) {
- token = peek_token (&val, (unsigned *)0, cfile);
+ token = peek_token (&val, NULL, cfile);
if (token == STRING) {
skip_token(&val, &data.len, cfile);
- data.buffer = (struct buffer *)0;
+ data.buffer = NULL;
+
if (!buffer_allocate (&data.buffer,
data.len + 1, MDL)) {
if (pc)
/* If we didn't find an existing class, allocate a new one. */
if (!class) {
/* Allocate the class structure... */
- status = class_allocate (&class, MDL);
+ if (type == CLASS_TYPE_SUBCLASS) {
+ status = subclass_allocate (&class, MDL);
+ } else {
+ status = class_allocate (&class, MDL);
+ }
if (pc) {
group_reference (&class -> group, pc -> group, MDL);
class_reference (&class -> superclass, pc, MDL);
statement that causes the vendor or user class ID to
be sent back in the reply. */
if (type == CLASS_TYPE_VENDOR || type == CLASS_TYPE_USER) {
- stmt = (struct executable_statement *)0;
+ stmt = NULL;
if (!executable_statement_allocate (&stmt, MDL))
log_fatal ("no memory for class statement.");
stmt -> op = supersede_option_statement;
/* Spawned classes don't have to have their own settings. */
if (class -> superclass) {
- token = peek_token (&val, (unsigned *)0, cfile);
+ token = peek_token (&val, NULL, cfile);
if (token == SEMI) {
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
+
if (cp)
status = class_reference (cp, class, MDL);
class_dereference (&class, MDL);
}
do {
- token = peek_token (&val, (unsigned *)0, cfile);
+ token = peek_token (&val, NULL, cfile);
if (token == RBRACE) {
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
break;
} else if (token == END_OF_FILE) {
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
parse_warn (cfile, "unexpected end of file");
break;
} else if (token == DYNAMIC) {
class->flags |= CLASS_DECL_DYNAMIC;
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
if (!parse_semi (cfile))
break;
continue;
} else if (token == TOKEN_DELETED) {
class->flags |= CLASS_DECL_DELETED;
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
if (!parse_semi (cfile))
break;
continue;
skip_to_semi (cfile);
break;
}
- skip_token(&val, (unsigned *)0, cfile);
- token = peek_token (&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
+ token = peek_token (&val, NULL, cfile);
if (token != IF)
goto submatch;
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
if (matchedonce) {
parse_warn(cfile, "A class may only have "
"one 'match if' clause.");
parse_semi (cfile);
}
} else if (token == SPAWN) {
- skip_token(&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
if (pc) {
parse_warn (cfile,
"invalid spawn in subclass.");
break;
}
class -> spawning = 1;
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token (&val, NULL, cfile);
if (token != WITH) {
parse_warn (cfile,
"expecting with after spawn");
parse_semi (cfile);
}
} else if (token == LEASE) {
- skip_token(&val, (unsigned *)0, cfile);
- token = next_token (&val, (unsigned *)0, cfile);
+ skip_token(&val, NULL, cfile);
+ token = next_token (&val, NULL, cfile);
if (token != LIMIT) {
parse_warn (cfile, "expecting \"limit\"");
if (token != SEMI)
skip_to_semi (cfile);
break;
}
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token (&val, NULL, cfile);
if (token != NUMBER) {
parse_warn (cfile, "expecting a number");
if (token != SEMI)
parse_semi (cfile);
} else {
declaration = parse_statement (cfile, class -> group,
- CLASS_DECL,
- (struct host_decl *)0,
+ CLASS_DECL, NULL,
declaration);
}
} while (1);
OMAPI object interfaces for the DHCP server. */
/*
- * Copyright (c) 2004-2009,2012,2013 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2012-2013 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
dhcp_lease_destroy,
dhcp_lease_signal_handler,
dhcp_lease_stuff_values,
- dhcp_lease_lookup,
+ dhcp_lease_lookup,
dhcp_lease_create,
dhcp_lease_remove,
#if defined (COMPACT_LEASES)
dhcp_class_destroy,
dhcp_class_signal_handler,
dhcp_class_stuff_values,
- dhcp_class_lookup,
+ dhcp_class_lookup,
dhcp_class_create,
dhcp_class_remove, 0, 0, 0,
sizeof (struct class), 0,
dhcp_class_destroy,
dhcp_subclass_signal_handler,
dhcp_subclass_stuff_values,
- dhcp_subclass_lookup,
+ dhcp_subclass_lookup,
dhcp_subclass_create,
dhcp_subclass_remove, 0, 0, 0,
sizeof (struct class), 0, RC_MISC);
dhcp_pool_destroy,
dhcp_pool_signal_handler,
dhcp_pool_stuff_values,
- dhcp_pool_lookup,
+ dhcp_pool_lookup,
dhcp_pool_create,
dhcp_pool_remove, 0, 0, 0,
sizeof (struct pool), 0, RC_MISC);
dhcp_host_destroy,
dhcp_host_signal_handler,
dhcp_host_stuff_values,
- dhcp_host_lookup,
+ dhcp_host_lookup,
dhcp_host_create,
dhcp_host_remove, 0, 0, 0,
sizeof (struct host_decl),
dhcp_failover_state_destroy,
dhcp_failover_state_signal,
dhcp_failover_state_stuff,
- dhcp_failover_state_lookup,
+ dhcp_failover_state_lookup,
dhcp_failover_state_create,
dhcp_failover_state_remove,
0, 0, 0,
status = omapi_get_int_value (&bar, value);
if (status != ISC_R_SUCCESS)
return status;
-
+
if (bar < 1 || bar > FTS_LAST)
return DHCP_R_INVALIDARG;
nls = binding_state_names [bar - 1];
ols = binding_state_names [lease -> binding_state - 1];
else
ols = "unknown state";
-
+
if (lease -> binding_state != bar) {
lease -> next_binding_state = bar;
if (supersede_lease (lease, 0, 1, 1, 1)) {
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
if (!lease -> scope) {
if (!binding_scope_allocate (&lease -> scope, MDL))
return ISC_R_NOMEMORY;
/* Write out all the values. */
- status = omapi_connection_put_name (c, "state");
+ status = omapi_connection_put_named_uint32(c, "state",
+ lease->binding_state);
if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32 (c, sizeof (int));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32 (c, lease -> binding_state);
- if (status != ISC_R_SUCCESS)
- return status;
+ return (status);
status = omapi_connection_put_name (c, "ip-address");
if (status != ISC_R_SUCCESS)
if (status != ISC_R_SUCCESS)
return status;
- status = omapi_connection_put_name (c, "hardware-type");
+ status = omapi_connection_put_named_uint32(c, "hardware-type",
+ lease->hardware_addr.hbuf[0]);
if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32 (c, sizeof (int));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32
- (c, lease -> hardware_addr.hbuf [0]);
- if (status != ISC_R_SUCCESS)
- return status;
+ return (status);
}
/* TIME values may be 64-bit, depending on system architecture.
* 32-bit, code.
*/
bouncer = (u_int32_t)lease->ends;
- status = omapi_connection_put_name(c, "ends");
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, sizeof(bouncer));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, bouncer);
+ status = omapi_connection_put_named_uint32(c, "ends", bouncer);
if (status != ISC_R_SUCCESS)
- return status;
+ return (status);
bouncer = (u_int32_t)lease->starts;
- status = omapi_connection_put_name(c, "starts");
+ status = omapi_connection_put_named_uint32(c, "starts", bouncer);
if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, sizeof(bouncer));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, bouncer);
- if (status != ISC_R_SUCCESS)
- return status;
+ return (status);
bouncer = (u_int32_t)lease->tstp;
- status = omapi_connection_put_name(c, "tstp");
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, sizeof(bouncer));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, bouncer);
+ status = omapi_connection_put_named_uint32(c, "tstp", bouncer);
if (status != ISC_R_SUCCESS)
- return status;
+ return (status);
bouncer = (u_int32_t)lease->tsfp;
- status = omapi_connection_put_name(c, "tsfp");
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, sizeof(bouncer));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, bouncer);
+ status = omapi_connection_put_named_uint32(c, "tsfp", bouncer);
if (status != ISC_R_SUCCESS)
return status;
bouncer = (u_int32_t)lease->atsfp;
- status = omapi_connection_put_name(c, "atsfp");
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, sizeof(bouncer));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, bouncer);
+ status = omapi_connection_put_named_uint32(c, "atsfp", bouncer);
if (status != ISC_R_SUCCESS)
return status;
bouncer = (u_int32_t)lease->cltt;
- status = omapi_connection_put_name(c, "cltt");
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, sizeof(bouncer));
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32(c, bouncer);
+ status = omapi_connection_put_named_uint32(c, "cltt", bouncer);
if (status != ISC_R_SUCCESS)
return status;
tv->value->u.buffer.value,
tv->value->u.buffer.len, MDL);
omapi_value_dereference (&tv, MDL);
-
+
if (*lp && *lp != (omapi_object_t *)lease) {
omapi_object_dereference (lp, MDL);
lease_dereference (&lease, MDL);
return DHCP_R_INVALIDARG;
host = (struct host_decl *)h;
- /* XXX For now, we can only set these values on new host objects.
+ /* XXX For now, we can only set these values on new host objects.
XXX Soon, we need to be able to update host objects. */
if (!omapi_ds_strcmp (name, "name")) {
if (host -> name)
return ISC_R_EXISTS;
if (value && (value -> type == omapi_datatype_data ||
- value -> type == omapi_datatype_string)) {
+ value -> type == omapi_datatype_string)) {
host -> name = dmalloc (value -> u.buffer.len + 1,
MDL);
if (!host -> name)
if (!omapi_ds_strcmp (name, "group")) {
if (value && (value -> type == omapi_datatype_data ||
- value -> type == omapi_datatype_string)) {
+ value -> type == omapi_datatype_string)) {
struct group_object *group;
group = (struct group_object *)0;
group_hash_lookup (&group, group_name_hash,
if (host -> interface.hlen)
return ISC_R_EXISTS;
if (value && (value -> type == omapi_datatype_data ||
- value -> type == omapi_datatype_string)) {
+ value -> type == omapi_datatype_string)) {
if (value -> u.buffer.len >
(sizeof host -> interface.hbuf) - 1)
return DHCP_R_INVALIDARG;
if (host -> client_identifier.data)
return ISC_R_EXISTS;
if (value && (value -> type == omapi_datatype_data ||
- value -> type == omapi_datatype_string)) {
+ value -> type == omapi_datatype_string)) {
if (!buffer_allocate (&host -> client_identifier.buffer,
value -> u.buffer.len, MDL))
return ISC_R_NOMEMORY;
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
return DHCP_R_UNKNOWNATTRIBUTE;
}
if (status != ISC_R_SUCCESS)
return status;
- status = omapi_connection_put_name (c, "hardware-type");
- if (status != ISC_R_SUCCESS)
- return status;
- status = omapi_connection_put_uint32 (c, sizeof (int));
- if (status != ISC_R_SUCCESS)
- return status;
- status = (omapi_connection_put_uint32
- (c, host -> interface.hbuf [0]));
+ status = omapi_connection_put_named_uint32(c, "hardware-type",
+ host->interface.hbuf[0]);
if (status != ISC_R_SUCCESS)
return status;
}
host = (struct host_decl *)0;
host_hash_lookup (&host, host_hw_addr_hash, haddr, len, MDL);
dfree (haddr, MDL);
-
+
if (*lp && *lp != (omapi_object_t *)host) {
omapi_object_dereference (lp, MDL);
if (host)
host_hash_lookup (&host, host_hw_addr_hash,
l -> hardware_addr.hbuf,
l -> hardware_addr.hlen, MDL);
-
+
if (host && *lp && *lp != (omapi_object_t *)host) {
omapi_object_dereference (lp, MDL);
if (host)
tv -> value -> u.buffer.value,
tv -> value -> u.buffer.len, MDL);
omapi_value_dereference (&tv, MDL);
-
+
if (*lp && *lp != (omapi_object_t *)host) {
omapi_object_dereference (lp, MDL);
if (host)
} else if (!host || (host -> flags & HOST_DECL_DELETED)) {
if (host)
host_dereference (&host, MDL);
- return ISC_R_NOTFOUND;
+ return ISC_R_NOTFOUND;
} else if (!*lp) {
/* XXX fix so that hash lookup itself creates
XXX the reference. */
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
return DHCP_R_UNKNOWNATTRIBUTE;
}
omapi_object_t *id,
omapi_object_t *h)
{
- /* h should point to (struct pool *) */
+ struct pool *pool;
isc_result_t status;
- if (h -> type != dhcp_type_pool)
- return DHCP_R_INVALIDARG;
+ if (h->type != dhcp_type_pool)
+ return (DHCP_R_INVALIDARG);
+ pool = (struct pool *)h;
- /* Can't stuff pool values yet. */
+ /*
+ * I don't think we can actually find a pool yet
+ * but include the output of interesting values
+ * for when we do
+ */
+ status = omapi_connection_put_named_uint32(c, "lease-count",
+ ((u_int32_t)
+ pool->lease_count));
+ if (status != ISC_R_SUCCESS)
+ return (status);
+
+ status = omapi_connection_put_named_uint32(c, "free-leases",
+ ((u_int32_t)
+ pool->free_leases));
+ if (status != ISC_R_SUCCESS)
+ return (status);
+
+ status = omapi_connection_put_named_uint32(c, "backup-leases",
+ ((u_int32_t)
+ pool->backup_leases));
+ if (status != ISC_R_SUCCESS)
+ return (status);
+ /* we could add time stamps but lets wait on those */
/* Write out the inner object, if any. */
- if (h -> inner && h -> inner -> type -> stuff_values) {
- status = ((*(h -> inner -> type -> stuff_values))
- (c, id, h -> inner));
+ if (h->inner && h->inner->type->stuff_values) {
+ status = ((*(h->inner->type->stuff_values))
+ (c, id, h->inner));
if (status == ISC_R_SUCCESS)
- return status;
+ return (status);
}
- return ISC_R_SUCCESS;
+ return (ISC_R_SUCCESS);
}
isc_result_t dhcp_pool_lookup (omapi_object_t **lp,
if (class->superclass != NULL)
class_dereference(&class->superclass, MDL);
-
class_reference(&class->superclass, superclass, MDL);
- } else if (value -> type == omapi_datatype_data ||
- value -> type == omapi_datatype_string) {
+
+ if (class->group != NULL)
+ group_dereference(&class->group, MDL);
+ group_reference(&class->group, superclass->group, MDL);
+
+ class->lease_limit = superclass->lease_limit;
+ if (class->lease_limit != 0) {
+ class->billed_leases =
+ dmalloc(class->lease_limit *
+ sizeof(struct lease *),
+ MDL);
+ if (class->billed_leases == NULL) {
+ return ISC_R_NOMEMORY;
+ }
+ }
+
+ } else if (value->type == omapi_datatype_data ||
+ value->type == omapi_datatype_string) {
class->name = dmalloc(value->u.buffer.len + 1, MDL);
if (!class->name)
return ISC_R_NOMEMORY;
} else
return DHCP_R_INVALIDARG;
- /*
+ /*
* Currently no way to get here, if we update the above
* code so that we do get here this return needs to be
* uncommented.
if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass)
return DHCP_R_INVALIDARG;
-
-#if defined (DEBUG_MEMORY_LEAKAGE) || \
- defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct class *class = (struct class *)h;
+
if (class -> nic)
class_dereference (&class -> nic, file, line);
if (class -> superclass)
file, line);
if (class -> superclass)
class_dereference (&class -> superclass, file, line);
-#endif
return ISC_R_SUCCESS;
}
int updatep = 0;
int issubclass;
- issubclass = (h -> type == dhcp_type_subclass);
+ issubclass = (h->type == dhcp_type_subclass);
if (!strcmp (name, "updated")) {
-
+
if (!issubclass) {
- if (class -> name == 0 || strlen(class -> name) == 0) {
+ if (class->name == 0 || strlen(class->name) == 0) {
return DHCP_R_INVALIDARG;
}
} else {
- if (class -> superclass == 0) {
+ if (class->superclass == 0) {
return DHCP_R_INVALIDARG; /* didn't give name */
}
- if (class -> hash_string.data == NULL) {
+ if (class->hash_string.data == NULL) {
return DHCP_R_INVALIDARG;
}
}
if (issubclass) {
- if (!class -> superclass -> hash)
+ if (!class->superclass->hash)
class_new_hash(&class->superclass->hash,
SCLASS_HASH_SIZE, MDL);
- add_hash (class -> superclass -> hash,
- class -> hash_string.data,
- class -> hash_string.len,
- (void *)class, MDL);
+ class_hash_add(class->superclass->hash,
+ (const char *)class->hash_string.data,
+ class->hash_string.len,
+ (void *)class, MDL);
}
-
-
+
#ifdef DEBUG_OMAPI
if (issubclass) {
log_debug ("OMAPI added subclass %s",
- class -> superclass -> name);
+ class->superclass->name);
} else {
- log_debug ("OMAPI added class %s", class -> name);
+ log_debug ("OMAPI added class %s", class->name);
}
#endif
-
+
status = enter_class (class, 1, 1);
if (status != ISC_R_SUCCESS)
return status;
}
/* Try to find some inner object that can take the value. */
- if (h -> inner && h -> inner -> type -> signal_handler) {
- status = ((*(h -> inner -> type -> signal_handler))
- (h -> inner, name, ap));
+ if (h->inner && h->inner->type->signal_handler) {
+ status = ((*(h->inner->type->signal_handler))
+ (h->inner, name, ap));
if (status == ISC_R_SUCCESS)
return status;
}
return class_signal_handler(h, name, ap);
}
-isc_result_t dhcp_class_stuff_values (omapi_object_t *c,
- omapi_object_t *id,
- omapi_object_t *h)
+
+/*
+ * Routine to put out generic class & subclass information
+ */
+isc_result_t class_stuff_values (omapi_object_t *c,
+ omapi_object_t *id,
+ omapi_object_t *h)
{
- /* h should point to (struct class *) */
+ struct class *class;
isc_result_t status;
- if (h -> type != dhcp_type_class)
- return DHCP_R_INVALIDARG;
+ class = (struct class *)h;
- /* Can't stuff class values yet. */
+ status = omapi_connection_put_named_uint32(c, "lease-limit",
+ ((u_int32_t)
+ class->lease_limit));
+ if (status != ISC_R_SUCCESS)
+ return (status);
+
+ status = omapi_connection_put_named_uint32(c, "leases-used",
+ ((u_int32_t)
+ class->leases_consumed));
+ if (status != ISC_R_SUCCESS)
+ return (status);
/* Write out the inner object, if any. */
- if (h -> inner && h -> inner -> type -> stuff_values) {
- status = ((*(h -> inner -> type -> stuff_values))
- (c, id, h -> inner));
+ if (h->inner && h->inner->type->stuff_values) {
+ status = ((*(h->inner->type->stuff_values))
+ (c, id, h->inner));
if (status == ISC_R_SUCCESS)
- return status;
+ return (status);
}
- return ISC_R_SUCCESS;
+ return (ISC_R_SUCCESS);
+}
+
+
+isc_result_t dhcp_class_stuff_values (omapi_object_t *c,
+ omapi_object_t *id,
+ omapi_object_t *h)
+{
+ if (h->type != dhcp_type_class)
+ return (DHCP_R_INVALIDARG);
+
+ /* add any class specific items here */
+
+ return (class_stuff_values(c, id, h));
}
static isc_result_t class_lookup (omapi_object_t **lp,
omapi_object_t *id, omapi_object_t *ref,
omapi_object_type_t *typewanted)
{
- omapi_value_t *nv = (omapi_value_t *)0;
- omapi_value_t *hv = (omapi_value_t *)0;
+ omapi_value_t *nv = NULL;
+ omapi_value_t *hv = NULL;
isc_result_t status;
struct class *class = 0;
struct class *subclass = 0;
*lp = NULL;
-
+
+ if (ref == NULL)
+ return (DHCP_R_NOKEYS);
+
/* see if we have a name */
- status = omapi_get_value_str (ref, id, "name", &nv);
+ status = omapi_get_value_str(ref, id, "name", &nv);
if (status == ISC_R_SUCCESS) {
- char *name = dmalloc(nv -> value -> u.buffer.len + 1, MDL);
+ char *name = dmalloc(nv->value->u.buffer.len + 1, MDL);
memcpy (name,
- nv -> value -> u.buffer.value,
- nv -> value -> u.buffer.len);
+ nv->value->u.buffer.value,
+ nv->value->u.buffer.len);
- omapi_value_dereference (&nv, MDL);
+ omapi_value_dereference(&nv, MDL);
find_class(&class, name, MDL);
dfree(name, MDL);
-
+
if (class == NULL) {
- return ISC_R_NOTFOUND;
+ return (ISC_R_NOTFOUND);
}
if (typewanted == dhcp_type_subclass) {
- status = omapi_get_value_str (ref, id,
- "hashstring", &hv);
+ status = omapi_get_value_str(ref, id,
+ "hashstring", &hv);
if (status != ISC_R_SUCCESS) {
class_dereference(&class, MDL);
- return DHCP_R_NOKEYS;
+ return (DHCP_R_NOKEYS);
}
- if (hv -> value -> type != omapi_datatype_data &&
- hv -> value -> type != omapi_datatype_string) {
+ if (hv->value->type != omapi_datatype_data &&
+ hv->value->type != omapi_datatype_string) {
class_dereference(&class, MDL);
- omapi_value_dereference (&hv, MDL);
- return DHCP_R_NOKEYS;
+ omapi_value_dereference(&hv, MDL);
+ return (DHCP_R_NOKEYS);
}
-
- class_hash_lookup (&subclass, class -> hash,
- (const char *)
- hv -> value -> u.buffer.value,
- hv -> value -> u.buffer.len, MDL);
-
- omapi_value_dereference (&hv, MDL);
+
+ class_hash_lookup(&subclass, class->hash,
+ (const char *)
+ hv->value->u.buffer.value,
+ hv->value->u.buffer.len, MDL);
+
+ omapi_value_dereference(&hv, MDL);
class_dereference(&class, MDL);
-
+
if (subclass == NULL) {
- return ISC_R_NOTFOUND;
+ return (ISC_R_NOTFOUND);
}
class_reference(&class, subclass, MDL);
class_dereference(&subclass, MDL);
}
-
-
+
/* Don't return the object if the type is wrong. */
- if (class -> type != typewanted) {
- class_dereference (&class, MDL);
- return DHCP_R_INVALIDARG;
+ if (class->type != typewanted) {
+ class_dereference(&class, MDL);
+ return (DHCP_R_INVALIDARG);
}
-
- if (class -> flags & CLASS_DECL_DELETED) {
- class_dereference (&class, MDL);
+
+ if (class->flags & CLASS_DECL_DELETED) {
+ class_dereference(&class, MDL);
+ return (ISC_R_NOTFOUND);
}
omapi_object_reference(lp, (omapi_object_t *)class, MDL);
-
- return ISC_R_SUCCESS;
+ class_dereference(&class, MDL);
+
+ return (ISC_R_SUCCESS);
}
- return DHCP_R_NOKEYS;
+ return (DHCP_R_NOKEYS);
}
{
struct class *cp = 0;
isc_result_t status;
-
+
status = class_allocate(&cp, MDL);
if (status != ISC_R_SUCCESS)
- return status;
-
- group_reference (&cp -> group, root_group, MDL);
- cp -> flags = CLASS_DECL_DYNAMIC;
- status = omapi_object_reference (lp, (omapi_object_t *)cp, MDL);
- class_dereference (&cp, MDL);
- return status;
+ return (status);
+
+ clone_group(&cp->group, root_group, MDL);
+ cp->flags = CLASS_DECL_DYNAMIC;
+ status = omapi_object_reference(lp, (omapi_object_t *)cp, MDL);
+ class_dereference(&cp, MDL);
+ return (status);
}
isc_result_t dhcp_class_remove (omapi_object_t *lp,
#ifdef DEBUG_OMAPI
log_debug ("OMAPI delete class %s", cp -> name);
#endif
-
+
delete_class (cp, 1);
return ISC_R_SUCCESS;
}
subclass = (struct class *)h;
if (subclass -> name != 0)
return DHCP_R_INVALIDARG;
-
+
/* XXXJAB No values to get yet. */
/* Try to find some inner object that can provide the value. */
omapi_object_t *h)
{
struct class *subclass;
- isc_result_t status;
- if (h -> type != dhcp_type_class)
- return DHCP_R_INVALIDARG;
+ if (h->type != dhcp_type_subclass)
+ return (DHCP_R_INVALIDARG);
subclass = (struct class *)h;
- if (subclass -> name != 0)
- return DHCP_R_INVALIDARG;
-
-
- /* Can't stuff subclass values yet. */
+ if (subclass->name != 0)
+ return (DHCP_R_INVALIDARG);
- /* Write out the inner object, if any. */
- if (h -> inner && h -> inner -> type -> stuff_values) {
- status = ((*(h -> inner -> type -> stuff_values))
- (c, id, h -> inner));
- if (status == ISC_R_SUCCESS)
- return status;
- }
+ /* add any subclass specific items here */
- return ISC_R_SUCCESS;
+ return (class_stuff_values(c, id, h));
}
isc_result_t dhcp_subclass_lookup (omapi_object_t **lp,
struct class *cp = 0;
isc_result_t status;
-/*
- * XXX
- * NOTE: subclasses and classes have the same internal type, which makes it
- * difficult to tell them apart. Specifically, in this function we need to
- * create a class object (because there is no such thing as a subclass
- * object), but one field of the class object is the type (which has the
- * value dhcp_type_class), and it is from here that all the other omapi
- * functions are accessed. So, even though there's a whole suite of
- * subclass functions registered, they won't get used. Now we could change
- * the type pointer after creating the class object, but I'm not certain
- * that won't break something else.
- */
-
status = subclass_allocate(&cp, MDL);
if (status != ISC_R_SUCCESS)
return status;
- group_reference (&cp -> group, root_group, MDL);
+ group_reference (&cp->group, root_group, MDL);
+
+ cp->flags = CLASS_DECL_DYNAMIC;
- cp -> flags = CLASS_DECL_DYNAMIC;
-
status = omapi_object_reference (lp, (omapi_object_t *)cp, MDL);
subclass_dereference (&cp, MDL);
return status;
isc_result_t dhcp_subclass_remove (omapi_object_t *lp,
omapi_object_t *id)
{
-#if 1
-
- log_fatal("calling dhcp_subclass_set_value");
- /* this should never be called see dhcp_subclass_create for why */
-
-#else
-
struct class *cp;
if (lp -> type != dhcp_type_subclass)
return DHCP_R_INVALIDARG;
#ifdef DEBUG_OMAPI
log_debug ("OMAPI delete subclass %s", cp -> name);
#endif
-
+
delete_class (cp, 1);
-#endif
-
return ISC_R_SUCCESS;
}
if (!bp && !createp) {
dfree (nname, MDL);
return DHCP_R_UNKNOWNATTRIBUTE;
- }
+ }
if (!value) {
dfree (nname, MDL);
if (!bp)
omapi_typed_data_dereference (&td, MDL);
return status;
}
-
+
omapi_data_string_reference (&(*value) -> name, name, MDL);
omapi_typed_data_reference (&(*value) -> value, td, MDL);
omapi_typed_data_dereference (&td, MDL);