summaryrefslogtreecommitdiff
path: root/server/omapi.c
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>2001-04-05 22:54:57 +0000
committerTed Lemon <source@isc.org>2001-04-05 22:54:57 +0000
commit5aa40fc5a0842f45d98d9ff7c1af0c5f359ac2a6 (patch)
tree09516148bd7e95f99daa06baf963bc1335d61fa5 /server/omapi.c
parentfb5f87935616067baba656857d1e7fafc71df941 (diff)
downloadisc-dhcp-5aa40fc5a0842f45d98d9ff7c1af0c5f359ac2a6.tar.gz
Add hooks for subclasses.
Diffstat (limited to 'server/omapi.c')
-rw-r--r--server/omapi.c160
1 files changed, 159 insertions, 1 deletions
diff --git a/server/omapi.c b/server/omapi.c
index 6fe0fc98..bd031b31 100644
--- a/server/omapi.c
+++ b/server/omapi.c
@@ -50,7 +50,7 @@
#ifndef lint
static char copyright[] =
-"$Id: omapi.c,v 1.43 2001/02/26 22:21:15 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: omapi.c,v 1.44 2001/04/05 22:54:57 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -59,6 +59,7 @@ static char copyright[] =
omapi_object_type_t *dhcp_type_lease;
omapi_object_type_t *dhcp_type_pool;
omapi_object_type_t *dhcp_type_class;
+omapi_object_type_t *dhcp_type_subclass;
omapi_object_type_t *dhcp_type_host;
#if defined (FAILOVER_PROTOCOL)
omapi_object_type_t *dhcp_type_failover_state;
@@ -107,6 +108,21 @@ void dhcp_db_objects_setup ()
log_fatal ("Can't register class object type: %s",
isc_result_totext (status));
+ status = omapi_object_type_register (&dhcp_type_subclass,
+ "subclass",
+ dhcp_subclass_set_value,
+ dhcp_subclass_get_value,
+ dhcp_subclass_destroy,
+ dhcp_subclass_signal_handler,
+ dhcp_subclass_stuff_values,
+ dhcp_subclass_lookup,
+ dhcp_subclass_create,
+ dhcp_subclass_remove, 0, 0, 0,
+ sizeof (struct class), 0);
+ if (status != ISC_R_SUCCESS)
+ log_fatal ("Can't register subclass object type: %s",
+ isc_result_totext (status));
+
status = omapi_object_type_register (&dhcp_type_pool,
"pool",
dhcp_pool_set_value,
@@ -1647,4 +1663,146 @@ isc_result_t dhcp_class_remove (omapi_object_t *lp,
return ISC_R_NOTIMPLEMENTED;
}
+isc_result_t dhcp_subclass_set_value (omapi_object_t *h,
+ omapi_object_t *id,
+ omapi_data_string_t *name,
+ omapi_typed_data_t *value)
+{
+ struct subclass *subclass;
+ isc_result_t status;
+ int foo;
+
+ if (h -> type != dhcp_type_subclass)
+ return ISC_R_INVALIDARG;
+ subclass = (struct subclass *)h;
+
+ /* No values to set yet. */
+
+ /* Try to find some inner object that can take the value. */
+ if (h -> inner && h -> inner -> type -> set_value) {
+ status = ((*(h -> inner -> type -> set_value))
+ (h -> inner, id, name, value));
+ if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
+ return status;
+ }
+
+ return ISC_R_NOTFOUND;
+}
+
+
+isc_result_t dhcp_subclass_get_value (omapi_object_t *h, omapi_object_t *id,
+ omapi_data_string_t *name,
+ omapi_value_t **value)
+{
+ struct subclass *subclass;
+ isc_result_t status;
+
+ if (h -> type != dhcp_type_subclass)
+ return ISC_R_INVALIDARG;
+ subclass = (struct subclass *)h;
+
+ /* No values to get yet. */
+
+ /* Try to find some inner object that can provide the value. */
+ if (h -> inner && h -> inner -> type -> get_value) {
+ status = ((*(h -> inner -> type -> get_value))
+ (h -> inner, id, name, value));
+ if (status == ISC_R_SUCCESS)
+ return status;
+ }
+ return ISC_R_NOTFOUND;
+}
+
+isc_result_t dhcp_subclass_destroy (omapi_object_t *h,
+ const char *file, int line)
+{
+ struct subclass *subclass;
+ isc_result_t status;
+
+ if (h -> type != dhcp_type_subclass)
+ return ISC_R_INVALIDARG;
+ subclass = (struct subclass *)h;
+
+ /* Can't destroy subclasss yet. */
+
+ return ISC_R_SUCCESS;
+}
+
+isc_result_t dhcp_subclass_signal_handler (omapi_object_t *h,
+ const char *name, va_list ap)
+{
+ struct subclass *subclass;
+ isc_result_t status;
+ int updatep = 0;
+
+ if (h -> type != dhcp_type_subclass)
+ return ISC_R_INVALIDARG;
+ subclass = (struct subclass *)h;
+
+ /* Can't write subclasss yet. */
+
+ /* Try to find some inner object that can take the value. */
+ if (h -> inner && h -> inner -> type -> get_value) {
+ status = ((*(h -> inner -> type -> signal_handler))
+ (h -> inner, name, ap));
+ if (status == ISC_R_SUCCESS)
+ return status;
+ }
+ if (updatep)
+ return ISC_R_SUCCESS;
+ return ISC_R_NOTFOUND;
+}
+
+isc_result_t dhcp_subclass_stuff_values (omapi_object_t *c,
+ omapi_object_t *id,
+ omapi_object_t *h)
+{
+ struct subclass *subclass;
+ isc_result_t status;
+
+ if (h -> type != dhcp_type_subclass)
+ return ISC_R_INVALIDARG;
+ subclass = (struct subclass *)h;
+
+ /* Can't stuff subclass values yet. */
+
+ /* 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;
+ }
+
+ return ISC_R_SUCCESS;
+}
+
+isc_result_t dhcp_subclass_lookup (omapi_object_t **lp,
+ omapi_object_t *id, omapi_object_t *ref)
+{
+ omapi_value_t *tv = (omapi_value_t *)0;
+ isc_result_t status;
+ struct subclass *subclass;
+
+ /* Can't look up subclasss yet. */
+
+ /* If we get to here without finding a subclass, no valid key was
+ specified. */
+ if (!*lp)
+ return ISC_R_NOKEYS;
+ return ISC_R_SUCCESS;
+}
+
+isc_result_t dhcp_subclass_create (omapi_object_t **lp,
+ omapi_object_t *id)
+{
+ return ISC_R_NOTIMPLEMENTED;
+}
+
+isc_result_t dhcp_subclass_remove (omapi_object_t *lp,
+ omapi_object_t *id)
+{
+ return ISC_R_NOTIMPLEMENTED;
+}
+
/* vim: set tabstop=8: */