2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-29 05:17:57 +00:00

- Don't try to return values that aren't present (and thus dump core).

- Fix ordering of a series of conditionals involved in looking up
  hosts (Brian Murrell).
- Add debugging messages when adding and removing hosts (Brian Murrell).
This commit is contained in:
Ted Lemon 1999-10-14 18:30:52 +00:00
parent 309267f056
commit c7775a73f6

View File

@ -29,7 +29,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: omapi.c,v 1.16 1999/10/08 03:43:15 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; "$Id: omapi.c,v 1.17 1999/10/14 18:30:52 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -179,33 +179,42 @@ isc_result_t dhcp_lease_get_value (omapi_object_t *h, omapi_object_t *id,
lease -> ip_addr.iabuf, lease -> ip_addr.iabuf,
lease -> ip_addr.len, lease -> ip_addr.len,
"dhcp_lease_get_value"); "dhcp_lease_get_value");
else if (!omapi_ds_strcmp (name, "dhcp-client-identifier")) else if (!omapi_ds_strcmp (name, "dhcp-client-identifier")) {
return omapi_make_const_value (value, name, return omapi_make_const_value (value, name,
lease -> uid, lease -> uid,
lease -> uid_len, lease -> uid_len,
"dhcp_lease_get_value"); "dhcp_lease_get_value");
else if (!omapi_ds_strcmp (name, "hostname")) } else if (!omapi_ds_strcmp (name, "hostname")) {
return omapi_make_string_value (value, name, if (lease -> hostname)
lease -> hostname, return omapi_make_string_value
"dhcp_lease_get_value"); (value, name, lease -> hostname,
else if (!omapi_ds_strcmp (name, "client-hostname")) "dhcp_lease_get_value");
return omapi_make_string_value (value, name, return ISC_R_NOTFOUND;
lease -> client_hostname, } else if (!omapi_ds_strcmp (name, "client-hostname")) {
"dhcp_lease_get_value"); if (lease -> client_hostname)
else if (!omapi_ds_strcmp (name, "ddns-fwd-name")) return omapi_make_string_value
return omapi_make_string_value (value, name, (value, name, lease -> client_hostname,
lease -> ddns_fwd_name, "dhcp_lease_get_value");
"dhcp_lease_get_value"); return ISC_R_NOTFOUND;
else if (!omapi_ds_strcmp (name, "ddns-rev-name")) } else if (!omapi_ds_strcmp (name, "ddns-fwd-name")) {
return omapi_make_string_value (value, name, if (lease -> ddns_fwd_name)
lease -> ddns_rev_name, return omapi_make_string_value
"dhcp_lease_get_value"); (value, name, lease -> ddns_fwd_name,
else if (!omapi_ds_strcmp (name, "host")) "dhcp_lease_get_value");
return omapi_make_handle_value (value, name, return ISC_R_NOTFOUND;
((omapi_object_t *) } else if (!omapi_ds_strcmp (name, "ddns-rev-name")) {
lease -> host), if (lease -> ddns_rev_name)
"dhcp_lease_get_value"); return omapi_make_string_value
else if (!omapi_ds_strcmp (name, "subnet")) (value, name, lease -> ddns_rev_name,
"dhcp_lease_get_value");
return ISC_R_NOTFOUND;
} else if (!omapi_ds_strcmp (name, "host")) {
if (lease -> host)
return omapi_make_handle_value
(value, name,
((omapi_object_t *)lease -> host),
"dhcp_lease_get_value");
} else if (!omapi_ds_strcmp (name, "subnet"))
return omapi_make_handle_value (value, name, return omapi_make_handle_value (value, name,
((omapi_object_t *) ((omapi_object_t *)
lease -> subnet), lease -> subnet),
@ -215,12 +224,14 @@ isc_result_t dhcp_lease_get_value (omapi_object_t *h, omapi_object_t *id,
((omapi_object_t *) ((omapi_object_t *)
lease -> pool), lease -> pool),
"dhcp_lease_get_value"); "dhcp_lease_get_value");
else if (!omapi_ds_strcmp (name, "billing-class")) else if (!omapi_ds_strcmp (name, "billing-class")) {
return omapi_make_handle_value (value, name, if (lease -> billing_class)
((omapi_object_t *) return omapi_make_handle_value
lease -> billing_class), (value, name,
"dhcp_lease_get_value"); ((omapi_object_t *)lease -> billing_class),
else if (!omapi_ds_strcmp (name, "hardware-address")) "dhcp_lease_get_value");
return ISC_R_NOTFOUND;
} else if (!omapi_ds_strcmp (name, "hardware-address"))
return omapi_make_const_value (value, name, return omapi_make_const_value (value, name,
lease -> hardware_addr.haddr, lease -> hardware_addr.haddr,
lease -> hardware_addr.hlen, lease -> hardware_addr.hlen,
@ -1232,6 +1243,9 @@ isc_result_t dhcp_host_signal_handler (omapi_object_t *h,
strcpy (host -> name, hnbuf); strcpy (host -> name, hnbuf);
} }
#ifdef DEBUG_OMAPI
log_debug ("OMAPI added host %s", host -> name);
#endif
status = enter_host (host, 1, 1); status = enter_host (host, 1, 1);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -1444,12 +1458,13 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp,
} else if (!host) { } else if (!host) {
if (!*lp) if (!*lp)
return ISC_R_NOTFOUND; return ISC_R_NOTFOUND;
} else if (!*lp) {
/* XXX fix so that hash lookup itself creates
XXX the reference. */
omapi_object_reference (lp,
(omapi_object_t *)host,
"dhcp_host_lookup");
} }
} else if (!*lp) {
/* XXX fix so that hash lookup itself creates
XXX the reference. */
omapi_object_reference (lp, (omapi_object_t *)host,
"dhcp_host_lookup");
} }
} }
@ -1506,6 +1521,9 @@ isc_result_t dhcp_host_remove (omapi_object_t *lp,
return ISC_R_INVALIDARG; return ISC_R_INVALIDARG;
hp = (struct host_decl *)lp; hp = (struct host_decl *)lp;
#ifdef DEBUG_OMAPI
log_debug ("OMAPI delete host %s", hp -> name);
#endif
delete_host (hp, 1); delete_host (hp, 1);
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
} }
@ -1651,3 +1669,4 @@ isc_result_t dhcp_pool_remove (omapi_object_t *lp,
return ISC_R_NOTIMPLEMENTED; return ISC_R_NOTIMPLEMENTED;
} }
/* vim: set tabstop=8: */