OMAPI object interfaces for the DHCP server. */
/*
- * Copyright (c) 2012,2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2012,2014-2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
{
+ struct subnet *subnet;
if (h -> type != dhcp_type_subnet)
return ISC_R_INVALIDARG;
-#if defined (DEBUG_MEMORY_LEAKAGE) || \
- defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
- struct subnet *subnet = (struct subnet *)h;
-
+ subnet = (struct subnet *)h;
if (subnet -> next_subnet)
subnet_dereference (&subnet -> next_subnet, file, line);
if (subnet -> next_sibling)
interface_dereference (&subnet -> interface, file, line);
if (subnet -> group)
group_dereference (&subnet -> group, file, line);
-#endif
return ISC_R_SUCCESS;
}
{
/* In this function h should be a (struct shared_network *) */
+ struct shared_network *shared_network;
+
if (h -> type != dhcp_type_shared_network)
return ISC_R_INVALIDARG;
-#if defined (DEBUG_MEMORY_LEAKAGE) || \
- defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
- struct shared_network *shared_network = (struct shared_network *)h;
+ shared_network = (struct shared_network *)h;
if (shared_network -> next)
shared_network_dereference (&shared_network -> next,
file, line);
&shared_network -> failover_peer,
file, line);
#endif
-#endif /* DEBUG_MEMORY_LEAKAGE */
return ISC_R_SUCCESS;
}
Routines for manipulating hash tables... */
/*
- * Copyright (c) 2009-2010,2014 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2014-2015 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
int i;
struct hash_bucket *hbc, *hbn = (struct hash_bucket *)0;
- for (i = 0; i < ptr -> hash_count; i++) {
+ for (i = 0; ptr != NULL && i < ptr -> hash_count; i++) {
for (hbc = ptr -> buckets [i]; hbc; hbc = hbn) {
hbn = hbc -> next;
if (ptr -> dereferencer && hbc -> value)
class_dereference
(&lease -> billing_class, file, line);
-#if defined (DEBUG_MEMORY_LEAKAGE) || \
- defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
- /* XXX we should never be destroying a lease with a next
- XXX pointer except on exit... */
- if (lease -> next)
- lease_dereference (&lease -> next, file, line);
- if (lease -> n_hw)
- lease_dereference (&lease -> n_hw, file, line);
- if (lease -> n_uid)
- lease_dereference (&lease -> n_uid, file, line);
- if (lease -> next_pending)
- lease_dereference (&lease -> next_pending, file, line);
-#endif
+ /* We no longer check for a next pointer as that should
+ * be cleared when we destroy the pool and as before we
+ * should only ever be doing that on exit.
+ if (lease->next)
+ lease_dereference (&lease->next, file, line);
+ */
+
+ if (lease->n_hw)
+ lease_dereference (&lease->n_hw, file, line);
+ if (lease->n_uid)
+ lease_dereference (&lease->n_uid, file, line);
+ if (lease->next_pending)
+ lease_dereference (&lease->next_pending, file, line);
return ISC_R_SUCCESS;
}
if (h -> type != dhcp_type_host)
return ISC_R_INVALIDARG;
-#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);
omapi_object_dereference ((omapi_object_t **)
&host -> named_group, file, line);
data_string_forget (&host -> auth_key_id, file, line);
-#endif
return ISC_R_SUCCESS;
}
}
isc_result_t dhcp_host_stuff_values (omapi_object_t *c,
- omapi_object_t *id,
- omapi_object_t *h)
+ omapi_object_t *id,
+ omapi_object_t *h)
{
struct host_decl *host;
isc_result_t status;
(struct option_state *)0,
&global_scope,
host -> fixed_addr, MDL)) {
+
status = omapi_connection_put_name (c, "ip-address");
- if (status != ISC_R_SUCCESS)
+ if (status != ISC_R_SUCCESS) {
+ data_string_forget (&ip_addrs, MDL);
return status;
+ }
+
status = omapi_connection_put_uint32 (c, ip_addrs.len);
- if (status != ISC_R_SUCCESS)
+ if (status != ISC_R_SUCCESS) {
+ data_string_forget (&ip_addrs, MDL);
return status;
+ }
+
status = omapi_connection_copyin (c,
ip_addrs.data, ip_addrs.len);
- if (status != ISC_R_SUCCESS)
+ if (status != ISC_R_SUCCESS) {
+ data_string_forget (&ip_addrs, MDL);
return status;
+ }
+
+ data_string_forget (&ip_addrs, MDL);
}
if (host -> client_identifier.len) {
isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
{
-#if defined (DEBUG_MEMORY_LEAKAGE) || \
- defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct permit *pc, *pn;
-#endif
if (h -> type != dhcp_type_pool)
return ISC_R_INVALIDARG;
-#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);
dhcp_failover_state_dereference (&pool -> failover_peer,
file, line);
#endif
+
for (pc = pool -> permit_list; pc; pc = pn) {
pn = pc -> next;
free_permit (pc, file, line);
free_permit (pc, file, line);
}
pool -> prohibit_list = (struct permit *)0;
-#endif
return ISC_R_SUCCESS;
}