summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-04-21 09:31:11 +0200
committerMartin Nagy <mnagy@redhat.com>2009-04-21 09:45:01 +0200
commit1ae7a3c4d2f018b251838ffdbd926c758cc2329c (patch)
treebd90619806396c26411b88cc52e2c272ce05103d /lib
parent2630da853b5bad2c02e3df46dccb727ca94d8666 (diff)
downloadbind_dynamic-1ae7a3c4d2f018b251838ffdbd926c758cc2329c.tar.gz
bind_dynamic-1ae7a3c4d2f018b251838ffdbd926c758cc2329c.tar.xz
bind_dynamic-1ae7a3c4d2f018b251838ffdbd926c758cc2329c.zip
Pass all necessary pointers in a packed structure.
Access to the dns_dyndb_arguments_t structure is done through a set of dns_dyndb_set_* and dns_dyndb_get_* functions. This will make it unnecessary to break the ABI if someone designing a plug-in will have a need for something more than there currently is. All that will be needed in that case will be an addition of set/get functions.
Diffstat (limited to 'lib')
-rw-r--r--lib/dns/dynamic_db.c117
-rw-r--r--lib/dns/include/dns/dynamic_db.h21
-rw-r--r--lib/dns/include/dns/types.h1
3 files changed, 133 insertions, 6 deletions
diff --git a/lib/dns/dynamic_db.c b/lib/dns/dynamic_db.c
index 662fc06..f11584d 100644
--- a/lib/dns/dynamic_db.c
+++ b/lib/dns/dynamic_db.c
@@ -21,13 +21,17 @@
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/result.h>
+#include <isc/task.h>
#include <isc/types.h>
#include <isc/util.h>
#include <dns/dynamic_db.h>
#include <dns/log.h>
#include <dns/types.h>
+#include <dns/view.h>
+#include <dns/zone.h>
+#include <string.h>
#if HAVE_DLFCN_H
#include <dlfcn.h>
@@ -40,8 +44,7 @@
typedef isc_result_t (*register_func_t)(isc_mem_t *mctx, const char *name,
- const char * const *argv, dns_view_t *view,
- dns_zonemgr_t *zmgr);
+ const char * const *argv, dns_dyndb_arguments_t *dyndb_args);
typedef void (*destroy_func_t)(void);
typedef struct dyndb_implementation dyndb_implementation_t;
@@ -54,6 +57,13 @@ struct dyndb_implementation {
LINK(dyndb_implementation_t) link;
};
+struct dns_dyndb_arguments {
+ dns_view_t *view;
+ dns_zonemgr_t *zmgr;
+ isc_task_t *task;
+ isc_timermgr_t *timermgr;
+};
+
/* List of implementations. Locked by dyndb_lock. */
static LIST(dyndb_implementation_t) dyndb_implementations;
/* Locks dyndb_implementations. */
@@ -192,8 +202,7 @@ unload_library(dyndb_implementation_t **impp)
isc_result_t
dns_dynamic_db_load(const char *libname, const char *name, isc_mem_t *mctx,
- const char * const *argv, dns_view_t *view,
- dns_zonemgr_t *zmgr)
+ const char * const *argv, dns_dyndb_arguments_t *dyndb_args)
{
isc_result_t result;
dyndb_implementation_t *implementation = NULL;
@@ -201,7 +210,7 @@ dns_dynamic_db_load(const char *libname, const char *name, isc_mem_t *mctx,
RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS);
CHECK(load_library(mctx, libname, &implementation));
- CHECK(implementation->register_function(mctx, name, argv, view, zmgr));
+ CHECK(implementation->register_function(mctx, name, argv, dyndb_args));
LOCK(&dyndb_lock);
APPEND(dyndb_implementations, implementation, link);
@@ -237,3 +246,101 @@ dns_dynamic_db_cleanup(void)
isc_mutex_destroy(&dyndb_lock);
}
+
+dns_dyndb_arguments_t *
+dns_dyndb_arguments_create(isc_mem_t *mctx)
+{
+ dns_dyndb_arguments_t *args;
+
+ args = isc_mem_get(mctx, sizeof(*args));
+ if (args != NULL)
+ memset(args, 0, sizeof(*args));
+
+ return args;
+}
+
+void
+dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args)
+{
+ REQUIRE(args != NULL);
+
+ dns_dyndb_set_view(args, NULL);
+ dns_dyndb_set_zonemgr(args, NULL);
+ dns_dyndb_set_task(args, NULL);
+ dns_dyndb_set_timermgr(args, NULL);
+
+ isc_mem_put(mctx, args, sizeof(*args));
+}
+
+void
+dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view)
+{
+ REQUIRE(args != NULL);
+
+ if (args->view != NULL)
+ dns_view_detach(&args->view);
+ if (view != NULL)
+ dns_view_attach(view, &args->view);
+}
+
+dns_view_t *
+dns_dyndb_get_view(dns_dyndb_arguments_t *args)
+{
+ REQUIRE(args != NULL);
+
+ return args->view;
+}
+
+void
+dns_dyndb_set_zonemgr(dns_dyndb_arguments_t *args, dns_zonemgr_t *zmgr)
+{
+ REQUIRE(args != NULL);
+
+ if (args->zmgr != NULL)
+ dns_zonemgr_detach(&args->zmgr);
+ if (zmgr != NULL)
+ dns_zonemgr_attach(zmgr, &args->zmgr);
+}
+
+dns_zonemgr_t *
+dns_dyndb_get_zonemgr(dns_dyndb_arguments_t *args)
+{
+ REQUIRE(args != NULL);
+
+ return args->zmgr;
+}
+
+void
+dns_dyndb_set_task(dns_dyndb_arguments_t *args, isc_task_t *task)
+{
+ REQUIRE(args != NULL);
+
+ if (args->task != NULL)
+ isc_task_detach(&args->task);
+ if (task != NULL)
+ isc_task_attach(task, &args->task);
+}
+
+isc_task_t *
+dns_dyndb_get_task(dns_dyndb_arguments_t *args)
+{
+ REQUIRE(args != NULL);
+
+ return args->task;
+}
+
+void
+dns_dyndb_set_timermgr(dns_dyndb_arguments_t *args, isc_timermgr_t *timermgr)
+{
+ REQUIRE(args != NULL);
+
+ args->timermgr = timermgr;
+}
+
+isc_timermgr_t *
+dns_dyndb_get_timermgr(dns_dyndb_arguments_t *args)
+{
+ REQUIRE(args != NULL);
+
+ return args->timermgr;
+}
diff --git a/lib/dns/include/dns/dynamic_db.h b/lib/dns/include/dns/dynamic_db.h
index 24147ea..12f7a06 100644
--- a/lib/dns/include/dns/dynamic_db.h
+++ b/lib/dns/include/dns/dynamic_db.h
@@ -22,10 +22,29 @@
#include <dns/types.h>
+/*
+ * TODO:
+ * Reformat the prototypes.
+ * Add annotated comments.
+ */
+
isc_result_t dns_dynamic_db_load(const char *libname, const char *name,
isc_mem_t *mctx, const char * const *argv,
- dns_view_t *view, dns_zonemgr_t *zmgr);
+ dns_dyndb_arguments_t *dyndb_args);
void dns_dynamic_db_cleanup(void);
+dns_dyndb_arguments_t *dns_dyndb_arguments_create(isc_mem_t *mctx);
+void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args);
+
+void dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view);
+dns_view_t *dns_dyndb_get_view(dns_dyndb_arguments_t *args);
+void dns_dyndb_set_zonemgr(dns_dyndb_arguments_t *args, dns_zonemgr_t *zmgr);
+dns_zonemgr_t *dns_dyndb_get_zonemgr(dns_dyndb_arguments_t *args);
+void dns_dyndb_set_task(dns_dyndb_arguments_t *args, isc_task_t *task);
+isc_task_t *dns_dyndb_get_task(dns_dyndb_arguments_t *args);
+void dns_dyndb_set_timermgr(dns_dyndb_arguments_t *args,
+ isc_timermgr_t *timermgr);
+isc_timermgr_t *dns_dyndb_get_timermgr(dns_dyndb_arguments_t *args);
+
#endif
diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h
index 5223397..f434188 100644
--- a/lib/dns/include/dns/types.h
+++ b/lib/dns/include/dns/types.h
@@ -56,6 +56,7 @@ typedef struct dns_dbtable dns_dbtable_t;
typedef void dns_dbversion_t;
typedef struct dns_dlzimplementation dns_dlzimplementation_t;
typedef struct dns_dlzdb dns_dlzdb_t;
+typedef struct dns_dyndb_arguments dns_dyndb_arguments_t;
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t;
typedef struct dns_decompress dns_decompress_t;
typedef struct dns_dispatch dns_dispatch_t;