aboutsummaryrefslogtreecommitdiff
path: root/server/omapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'server/omapi.c')
-rw-r--r--server/omapi.c60
1 files changed, 26 insertions, 34 deletions
diff --git a/server/omapi.c b/server/omapi.c
index bbddaf9..ca03cd1 100644
--- a/server/omapi.c
+++ b/server/omapi.c
@@ -3,7 +3,7 @@
OMAPI object interfaces for the DHCP server. */
/*
- * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010,2012 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
@@ -480,12 +480,11 @@ isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_lease_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- struct lease *lease;
+ /* h should point to (struct lease *) */
isc_result_t status;
if (h -> type != dhcp_type_lease)
return DHCP_R_INVALIDARG;
- lease = (struct lease *)h;
if (!strcmp (name, "updated"))
return ISC_R_SUCCESS;
@@ -985,20 +984,21 @@ isc_result_t dhcp_host_set_value (omapi_object_t *h,
if (!omapi_ds_strcmp (name, "hardware-type")) {
int type;
- if (value && (value -> type == omapi_datatype_data &&
- value -> u.buffer.len == sizeof type)) {
- if (value -> u.buffer.len > sizeof type)
- return DHCP_R_INVALIDARG;
- memcpy (&type,
- value -> u.buffer.value,
- value -> u.buffer.len);
- type = ntohl (type);
- } else if (value -> type == omapi_datatype_int)
- type = value -> u.integer;
+ if ((value != NULL) &&
+ ((value->type == omapi_datatype_data) &&
+ (value->u.buffer.len == sizeof(type)))) {
+ if (value->u.buffer.len > sizeof(type))
+ return (DHCP_R_INVALIDARG);
+ memcpy(&type, value->u.buffer.value,
+ value->u.buffer.len);
+ type = ntohl(type);
+ } else if ((value != NULL) &&
+ (value->type == omapi_datatype_int))
+ type = value->u.integer;
else
- return DHCP_R_INVALIDARG;
- host -> interface.hbuf [0] = type;
- return ISC_R_SUCCESS;
+ return (DHCP_R_INVALIDARG);
+ host->interface.hbuf[0] = type;
+ return (ISC_R_SUCCESS);
}
if (!omapi_ds_strcmp (name, "dhcp-client-identifier")) {
@@ -1175,14 +1175,13 @@ isc_result_t dhcp_host_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_host_destroy (omapi_object_t *h, const char *file, int line)
{
- struct host_decl *host;
if (h -> type != dhcp_type_host)
return DHCP_R_INVALIDARG;
- host = (struct host_decl *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ struct host_decl *host = (struct host_decl *)h;
if (host -> n_ipaddr)
host_dereference (&host -> n_ipaddr, file, line);
if (host -> n_dynamic)
@@ -1388,7 +1387,7 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp,
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)
@@ -1594,12 +1593,11 @@ isc_result_t dhcp_pool_set_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* No values to set yet. */
@@ -1619,12 +1617,11 @@ isc_result_t dhcp_pool_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* No values to get yet. */
@@ -1640,7 +1637,6 @@ isc_result_t dhcp_pool_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
{
- struct pool *pool;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct permit *pc, *pn;
@@ -1648,10 +1644,10 @@ isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ struct pool *pool = (struct pool *)h;
if (pool -> next)
pool_dereference (&pool -> next, file, line);
if (pool -> group)
@@ -1692,13 +1688,12 @@ isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_pool_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* Can't write pools yet. */
@@ -1718,12 +1713,11 @@ isc_result_t dhcp_pool_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* Can't stuff pool values yet. */
@@ -1951,14 +1945,13 @@ isc_result_t dhcp_class_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_class_destroy (omapi_object_t *h, const char *file, int line)
{
- struct class *class;
if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass)
return DHCP_R_INVALIDARG;
- class = (struct class *)h;
#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)
@@ -2065,7 +2058,7 @@ class_signal_handler(omapi_object_t *h,
if (updatep)
return ISC_R_SUCCESS;
-
+
return ISC_R_NOTFOUND;
}
@@ -2083,12 +2076,11 @@ isc_result_t dhcp_class_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct class *class;
+ /* h should point to (struct 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. */