]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
move ns/hooks to dns/hooks
authorEvan Hunt <each@isc.org>
Wed, 19 Nov 2025 03:17:13 +0000 (19:17 -0800)
committerEvan Hunt <each@isc.org>
Fri, 21 Nov 2025 21:19:02 +0000 (13:19 -0800)
In preparation for allowing resolver plugins as well as query plugins,
the ns_hook* code has been moved to libdns and renamed to dns_hook*.

24 files changed:
bin/named/server.c
bin/named/zoneconf.c
bin/plugins/filter-a.c
bin/plugins/filter-aaaa.c
bin/plugins/synthrecord.c
bin/tests/system/hooks/driver/test-async.c
bin/tests/system/hooks/driver/test-syncplugin.c
lib/dns/hooks.c [moved from lib/ns/hooks.c with 77% similarity]
lib/dns/include/dns/hooks.h [moved from lib/ns/include/ns/hooks.h with 74% similarity]
lib/dns/include/dns/types.h
lib/dns/include/dns/view.h
lib/dns/meson.build
lib/isccfg/check.c
lib/ns/include/ns/query.h
lib/ns/include/ns/types.h
lib/ns/meson.build
lib/ns/query.c
tests/dns/meson.build
tests/dns/plugin_test.c [moved from tests/ns/plugin_test.c with 70% similarity]
tests/include/tests/dns.h
tests/include/tests/ns.h
tests/libtest/ns.c
tests/ns/meson.build
tests/ns/query_test.c

index f7955a421a2635d02f33496795a2f738f38a5021..61376514c88f7060ef8ea73821178f78d62f6816 100644 (file)
@@ -70,6 +70,7 @@
 #include <dns/fixedname.h>
 #include <dns/forward.h>
 #include <dns/geoip.h>
+#include <dns/hooks.h>
 #include <dns/journal.h>
 #include <dns/kasp.h>
 #include <dns/keymgr.h>
 #include <isccfg/namedconf.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/interfacemgr.h>
 #include <ns/listenlist.h>
 
@@ -3677,10 +3677,10 @@ named_register_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
                          const char *parameters, void *callback_data) {
        char full_path[PATH_MAX];
        isc_result_t result;
-       ns_hook_data_t *hookdata = callback_data;
+       dns_hook_data_t *hookdata = callback_data;
 
-       result = ns_plugin_expandpath(plugin_path, full_path,
-                                     sizeof(full_path));
+       result = dns_plugin_expandpath(plugin_path, full_path,
+                                      sizeof(full_path));
        if (result != ISC_R_SUCCESS) {
                isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
                              ISC_LOG_ERROR,
@@ -3690,9 +3690,9 @@ named_register_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
                return result;
        }
 
-       result = ns_plugin_register(full_path, parameters, config,
-                                   cfg_obj_file(obj), cfg_obj_line(obj),
-                                   isc_g_mctx, aclctx, hookdata);
+       result = dns_plugin_register(full_path, parameters, config,
+                                    cfg_obj_file(obj), cfg_obj_line(obj),
+                                    isc_g_mctx, aclctx, hookdata);
        if (result != ISC_R_SUCCESS) {
                isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
                              ISC_LOG_ERROR,
@@ -5155,18 +5155,18 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        }
 
        if (plugin_list != NULL) {
-               ns_hook_data_t hookdata = {
-                       .pluginctx = { .source = NS_HOOKSOURCE_VIEW }
+               dns_hook_data_t hookdata = {
+                       .pluginctx = { .source = DNS_HOOKSOURCE_VIEW }
                };
 
                INSIST(view->hooktable == NULL);
-               ns_hooktable_create(view->mctx, &hookdata.hooktable);
+               dns_hooktable_create(view->mctx, &hookdata.hooktable);
                view->hooktable = hookdata.hooktable;
-               view->hooktable_free = ns_hooktable_free;
+               view->hooktable_free = dns_hooktable_free;
 
-               ns_plugins_create(view->mctx, &hookdata.plugins);
+               dns_plugins_create(view->mctx, &hookdata.plugins);
                view->plugins = hookdata.plugins;
-               view->plugins_free = ns_plugins_free;
+               view->plugins_free = dns_plugins_free;
 
                CHECK(cfg_pluginlist_foreach(config, plugin_list, aclctx,
                                             named_register_one_plugin,
index 15a1a8c71a39a29dcc108a5cd946afd14bbcc224..95de20cfa2bf6c486cc701db1d17bc0ddc85129f 100644 (file)
@@ -26,6 +26,7 @@
 #include <dns/acl.h>
 #include <dns/db.h>
 #include <dns/fixedname.h>
+#include <dns/hooks.h>
 #include <dns/ipkeylist.h>
 #include <dns/journal.h>
 #include <dns/kasp.h>
@@ -44,7 +45,6 @@
 #include <dns/zone.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 
 #include <named/config.h>
 #include <named/globals.h>
@@ -2128,18 +2128,18 @@ named_zone_loadplugins(dns_zone_t *zone, const cfg_obj_t *config,
        }
 
        if (tpluginlist != NULL || zpluginlist != NULL) {
-               ns_hook_data_t hookdata = {
-                       .pluginctx = { .source = NS_HOOKSOURCE_ZONE,
+               dns_hook_data_t hookdata = {
+                       .pluginctx = { .source = DNS_HOOKSOURCE_ZONE,
                                       .origin = dns_zone_getorigin(zone) }
                };
                isc_mem_t *zmctx = dns_zone_getmctx(zone);
 
-               ns_hooktable_create(zmctx, &hookdata.hooktable);
+               dns_hooktable_create(zmctx, &hookdata.hooktable);
                dns_zone_sethooktable(zone, hookdata.hooktable,
-                                     ns_hooktable_free);
+                                     dns_hooktable_free);
 
-               ns_plugins_create(zmctx, &hookdata.plugins);
-               dns_zone_setplugins(zone, hookdata.plugins, ns_plugins_free);
+               dns_plugins_create(zmctx, &hookdata.plugins);
+               dns_zone_setplugins(zone, hookdata.plugins, dns_plugins_free);
 
                result = cfg_pluginlist_foreach(config, tpluginlist, aclctx,
                                                named_register_one_plugin,
index 2d98b706921bbdd9914b3229adce57bb32204d9f..86a99de2288edc9ce289f9acfbee4192fc5bcc8f 100644 (file)
@@ -32,6 +32,7 @@
 #include <dns/acl.h>
 #include <dns/db.h>
 #include <dns/enumtype.h>
+#include <dns/hooks.h>
 #include <dns/message.h>
 #include <dns/rdataset.h>
 #include <dns/types.h>
@@ -42,7 +43,6 @@
 #include <isccfg/grammar.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/query.h>
 #include <ns/types.h>
 
@@ -72,7 +72,7 @@ typedef struct filter_data {
 } filter_data_t;
 
 typedef struct filter_instance {
-       ns_plugin_t *module;
+       dns_plugin_t *module;
        isc_mem_t *mctx;
 
        /*
@@ -104,67 +104,68 @@ typedef struct filter_instance {
 /*
  * Forward declarations of functions referenced in install_hooks().
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_initialize(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp);
 
 /*%
  * Register the functions to be called at each hook point in 'hooktable', using
  * memory context 'mctx' for allocating copies of stack-allocated structures
- * passed to ns_hook_add().  Make sure 'inst' will be passed as the 'cbdata'
+ * passed to dns_hook_add().  Make sure 'inst' will be passed as the 'cbdata'
  * argument to every callback.
  */
 static void
-install_hooks(ns_hooktable_t *hooktable, isc_mem_t *mctx,
+install_hooks(dns_hooktable_t *hooktable, isc_mem_t *mctx,
              filter_instance_t *inst) {
-       const ns_hook_t filter_init = {
+       const dns_hook_t filter_init = {
                .action = filter_initialize,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_respbegin = {
+       const dns_hook_t filter_respbegin = {
                .action = filter_respond_begin,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_respanyfound = {
+       const dns_hook_t filter_respanyfound = {
                .action = filter_respond_any_found,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_prepresp = {
+       const dns_hook_t filter_prepresp = {
                .action = filter_prep_response_begin,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_donesend = {
+       const dns_hook_t filter_donesend = {
                .action = filter_query_done_send,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_reset = {
+       const dns_hook_t filter_reset = {
                .action = filter_freeclientstate,
                .action_data = inst,
        };
 
-       ns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &filter_init);
-       ns_hook_add(hooktable, mctx, NS_QUERY_AUTHZONE_ATTACHED, &filter_init);
-       ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN, &filter_respbegin);
-       ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
-                   &filter_respanyfound);
-       ns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
-                   &filter_prepresp);
-       ns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
-       ns_hook_add(hooktable, mctx, NS_QUERY_CLEANUP, &filter_reset);
+       dns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &filter_init);
+       dns_hook_add(hooktable, mctx, NS_QUERY_AUTHZONE_ATTACHED, &filter_init);
+       dns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN,
+                    &filter_respbegin);
+       dns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
+                    &filter_respanyfound);
+       dns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
+                    &filter_prepresp);
+       dns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
+       dns_hook_add(hooktable, mctx, NS_QUERY_CLEANUP, &filter_reset);
 }
 
 /**
@@ -312,13 +313,13 @@ cleanup:
 **/
 
 /*
- * Called by ns_plugin_register() to initialize the plugin and
+ * Called by dns_plugin_register() to initialize the plugin and
  * register hook functions into the view hook table.
  */
 isc_result_t
 plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
                unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
-               ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
+               dns_hooktable_t *hooktable, const dns_pluginctx_t *ctx,
                void **instp) {
        filter_instance_t *inst = NULL;
        isc_result_t result = ISC_R_SUCCESS;
@@ -360,7 +361,7 @@ cleanup:
 isc_result_t
 plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
             unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
-            const ns_pluginctx_t *ctx ISC_ATTR_UNUSED) {
+            const dns_pluginctx_t *ctx ISC_ATTR_UNUSED) {
        isc_result_t result = ISC_R_SUCCESS;
        cfg_obj_t *param_obj = NULL;
        isc_buffer_t b;
@@ -380,7 +381,7 @@ cleanup:
 }
 
 /*
- * Called by ns_plugins_free(); frees memory allocated by
+ * Called by dns_plugins_free(); frees memory allocated by
  * the module when it was registered.
  */
 void
@@ -406,7 +407,7 @@ plugin_destroy(void **instp) {
  */
 int
 plugin_version(void) {
-       return NS_PLUGIN_VERSION;
+       return DNS_PLUGIN_VERSION;
 }
 
 /**
@@ -618,7 +619,7 @@ process_section(const section_filter_t *filter) {
  * the state will be initialized on the first call, and the function bails off
  * early on the second call (the state is already initialized).
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_initialize(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -631,7 +632,7 @@ filter_initialize(void *arg, void *cbdata, isc_result_t *resp) {
                client_state_create(qctx, inst);
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
@@ -639,7 +640,7 @@ filter_initialize(void *arg, void *cbdata, isc_result_t *resp) {
  * the client address family and the settings of filter-a-on-v6 and
  * filter-a-on-v4.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -649,7 +650,7 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
 
        if (client_state == NULL) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (inst->v4_a != NONE || inst->v6_a != NONE) {
@@ -666,7 +667,7 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
                }
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
@@ -676,7 +677,7 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
  * (This version is for processing answers to explicit A queries; ANY
  * queries are handled in filter_respond_any_found().)
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -686,7 +687,7 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
 
        if (client_state == NULL) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (client_state->mode != BREAK_DNSSEC &&
@@ -694,7 +695,7 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
             (WANTDNSSEC(qctx->client) && qctx->sigrdataset != NULL &&
              dns_rdataset_isassociated(qctx->sigrdataset))))
        {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (qctx->qtype == dns_rdatatype_a) {
@@ -767,17 +768,17 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
 
                *resp = result;
 
-               return NS_HOOK_RETURN;
+               return DNS_HOOK_RETURN;
        }
 
        *resp = result;
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
  * When answering an ANY query, remove A if AAAA is present.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -804,7 +805,7 @@ filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
                process_section(&filter_answer);
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
@@ -812,7 +813,7 @@ filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
  * hide NS in the authority section if A was filtered in the answer
  * section.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -841,14 +842,14 @@ filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp) {
                }
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
  * If the client is being detached, then we can delete our persistent data
  * from hash table and return it to the memory pool.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -856,5 +857,5 @@ filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
        client_state_destroy(qctx, inst);
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
index dad917464cd4143c2ebb8afb53f465a14d651720..724de41e3c6c1cd0302cdcaea7db27d95651a774 100644 (file)
@@ -32,6 +32,7 @@
 #include <dns/acl.h>
 #include <dns/db.h>
 #include <dns/enumtype.h>
+#include <dns/hooks.h>
 #include <dns/message.h>
 #include <dns/rdataset.h>
 #include <dns/types.h>
@@ -42,7 +43,6 @@
 #include <isccfg/grammar.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/query.h>
 #include <ns/types.h>
 
@@ -72,7 +72,7 @@ typedef struct filter_data {
 } filter_data_t;
 
 typedef struct filter_instance {
-       ns_plugin_t *module;
+       dns_plugin_t *module;
        isc_mem_t *mctx;
 
        /*
@@ -104,67 +104,68 @@ typedef struct filter_instance {
 /*
  * Forward declarations of functions referenced in install_hooks().
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_initialize(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp);
 
 /*%
  * Register the functions to be called at each hook point in 'hooktable', using
  * memory context 'mctx' for allocating copies of stack-allocated structures
- * passed to ns_hook_add().  Make sure 'inst' will be passed as the 'cbdata'
+ * passed to dns_hook_add().  Make sure 'inst' will be passed as the 'cbdata'
  * argument to every callback.
  */
 static void
-install_hooks(ns_hooktable_t *hooktable, isc_mem_t *mctx,
+install_hooks(dns_hooktable_t *hooktable, isc_mem_t *mctx,
              filter_instance_t *inst) {
-       const ns_hook_t filter_init = {
+       const dns_hook_t filter_init = {
                .action = filter_initialize,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_respbegin = {
+       const dns_hook_t filter_respbegin = {
                .action = filter_respond_begin,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_respanyfound = {
+       const dns_hook_t filter_respanyfound = {
                .action = filter_respond_any_found,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_prepresp = {
+       const dns_hook_t filter_prepresp = {
                .action = filter_prep_response_begin,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_donesend = {
+       const dns_hook_t filter_donesend = {
                .action = filter_query_done_send,
                .action_data = inst,
        };
 
-       const ns_hook_t filter_reset = {
+       const dns_hook_t filter_reset = {
                .action = filter_freeclientstate,
                .action_data = inst,
        };
 
-       ns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &filter_init);
-       ns_hook_add(hooktable, mctx, NS_QUERY_AUTHZONE_ATTACHED, &filter_init);
-       ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN, &filter_respbegin);
-       ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
-                   &filter_respanyfound);
-       ns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
-                   &filter_prepresp);
-       ns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
-       ns_hook_add(hooktable, mctx, NS_QUERY_CLEANUP, &filter_reset);
+       dns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &filter_init);
+       dns_hook_add(hooktable, mctx, NS_QUERY_AUTHZONE_ATTACHED, &filter_init);
+       dns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN,
+                    &filter_respbegin);
+       dns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
+                    &filter_respanyfound);
+       dns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
+                    &filter_prepresp);
+       dns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
+       dns_hook_add(hooktable, mctx, NS_QUERY_CLEANUP, &filter_reset);
 }
 
 /**
@@ -315,13 +316,13 @@ cleanup:
 **/
 
 /*
- * Called by ns_plugin_register() to initialize the plugin and
+ * Called by dns_plugin_register() to initialize the plugin and
  * register hook functions into the view hook table.
  */
 isc_result_t
 plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
                unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
-               ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
+               dns_hooktable_t *hooktable, const dns_pluginctx_t *ctx,
                void **instp) {
        filter_instance_t *inst = NULL;
        isc_result_t result = ISC_R_SUCCESS;
@@ -364,7 +365,7 @@ cleanup:
 isc_result_t
 plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
             unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
-            const ns_pluginctx_t *ctx ISC_ATTR_UNUSED) {
+            const dns_pluginctx_t *ctx ISC_ATTR_UNUSED) {
        isc_result_t result = ISC_R_SUCCESS;
        cfg_obj_t *param_obj = NULL;
        isc_buffer_t b;
@@ -384,7 +385,7 @@ cleanup:
 }
 
 /*
- * Called by ns_plugins_free(); frees memory allocated by
+ * Called by dns_plugins_free(); frees memory allocated by
  * the module when it was registered.
  */
 void
@@ -410,7 +411,7 @@ plugin_destroy(void **instp) {
  */
 int
 plugin_version(void) {
-       return NS_PLUGIN_VERSION;
+       return DNS_PLUGIN_VERSION;
 }
 
 /**
@@ -622,7 +623,7 @@ process_section(const section_filter_t *filter) {
  * the state will be initialized on the first call, and the function bails off
  * early on the second call (the state is already initialized).
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_initialize(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -635,7 +636,7 @@ filter_initialize(void *arg, void *cbdata, isc_result_t *resp) {
                client_state_create(qctx, inst);
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
@@ -643,7 +644,7 @@ filter_initialize(void *arg, void *cbdata, isc_result_t *resp) {
  * the client address family and the settings of filter-aaaa-on-v4 and
  * filter-aaaa-on-v6.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -653,7 +654,7 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
 
        if (client_state == NULL) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (inst->v4_aaaa != NONE || inst->v6_aaaa != NONE) {
@@ -670,7 +671,7 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
                }
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
@@ -680,7 +681,7 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
  * (This version is for processing answers to explicit AAAA queries; ANY
  * queries are handled in filter_respond_any_found().)
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -690,7 +691,7 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
 
        if (client_state == NULL) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (client_state->mode != BREAK_DNSSEC &&
@@ -698,7 +699,7 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
             (WANTDNSSEC(qctx->client) && qctx->sigrdataset != NULL &&
              dns_rdataset_isassociated(qctx->sigrdataset))))
        {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (qctx->qtype == dns_rdatatype_aaaa) {
@@ -770,17 +771,17 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
 
                *resp = result;
 
-               return NS_HOOK_RETURN;
+               return DNS_HOOK_RETURN;
        }
 
        *resp = result;
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
  * When answering an ANY query, remove AAAA if A is present.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -807,7 +808,7 @@ filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
                process_section(&filter_answer);
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
@@ -815,7 +816,7 @@ filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
  * hide NS in the authority section if AAAA was filtered in the answer
  * section.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -844,14 +845,14 @@ filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp) {
                }
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 /*
  * If the client is being detached, then we can delete our persistent data
  * from hash table and return it to the memory pool.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        filter_instance_t *inst = (filter_instance_t *)cbdata;
@@ -859,5 +860,5 @@ filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
        client_state_destroy(qctx, inst);
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
index 1fab2a3a374486783045489a61965bd658071993..71335b4762e783064eb3be444fb9b531e8a4c959 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <dns/byaddr.h>
+#include <dns/hooks.h>
 #include <dns/rdatalist.h>
 #include <dns/view.h>
 
@@ -19,7 +20,8 @@
 #include <isccfg/cfg.h>
 #include <isccfg/grammar.h>
 
-#include <ns/hooks.h>
+#include <ns/client.h>
+#include <ns/query.h>
 
 #define CHECK(op)                              \
        do {                                   \
@@ -258,7 +260,7 @@ synthrecord_parseforward(synthrecord_t *inst, const dns_name_t *name,
        return false;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 synthrecord_forward(synthrecord_t *inst, query_ctx_t *qctx,
                    isc_result_t *resp) {
        isc_netaddr_t addr;
@@ -267,11 +269,11 @@ synthrecord_forward(synthrecord_t *inst, query_ctx_t *qctx,
        *resp = ISC_R_UNSET;
 
        if (!synthrecord_parseforward(inst, qname, &addr)) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (!synthrecord_allowedsynth(inst, &addr)) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (qctx->qtype != dns_rdatatype_a &&
@@ -285,7 +287,7 @@ synthrecord_forward(synthrecord_t *inst, query_ctx_t *qctx,
                 */
                qctx->client->message->rcode = dns_rcode_noerror;
                *resp = ns_query_done(qctx);
-               return NS_HOOK_RETURN;
+               return DNS_HOOK_RETURN;
        }
 
        if ((qctx->qtype == dns_rdatatype_a ||
@@ -316,10 +318,10 @@ synthrecord_forward(synthrecord_t *inst, query_ctx_t *qctx,
                *resp = ns_query_done(qctx);
        }
 
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 synthrecord_reverse(synthrecord_t *inst, query_ctx_t *qctx,
                    isc_result_t *resp) {
        isc_result_t result;
@@ -338,11 +340,11 @@ synthrecord_reverse(synthrecord_t *inst, query_ctx_t *qctx,
                              ISC_LOG_DEBUG(10),
                              "synthrecord ptr parsing error %s",
                              isc_result_totext(result));
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (!synthrecord_allowedsynth(inst, &qaddr)) {
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        if (qctx->qtype != dns_rdatatype_ptr &&
@@ -356,7 +358,7 @@ synthrecord_reverse(synthrecord_t *inst, query_ctx_t *qctx,
                 */
                qctx->client->message->rcode = dns_rcode_noerror;
                *resp = ns_query_done(qctx);
-               return NS_HOOK_RETURN;
+               return DNS_HOOK_RETURN;
        }
 
        isc_buffer_init(&anameb, anamebdata, sizeof(anamebdata));
@@ -368,7 +370,7 @@ synthrecord_reverse(synthrecord_t *inst, query_ctx_t *qctx,
                        ISC_LOG_DEBUG(1),
                        "synthrecord cannot create reverse answer name: %s",
                        isc_result_totext(result));
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        synthptrdata = (dns_rdata_ptr_t){
@@ -380,10 +382,10 @@ synthrecord_reverse(synthrecord_t *inst, query_ctx_t *qctx,
                                     dns_rdatatype_ptr);
        *resp = result;
 
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 synthrecord_entry(void *arg, void *cbdata, isc_result_t *resp) {
        synthrecord_t *inst = cbdata;
        query_ctx_t *qctx = arg;
@@ -599,10 +601,10 @@ cleanup:
 isc_result_t
 plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
                unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
-               ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
+               dns_hooktable_t *hooktable, const dns_pluginctx_t *ctx,
                void **instp) {
        synthrecord_t *inst = NULL;
-       ns_hook_t hook;
+       dns_hook_t hook;
        isc_result_t result;
 
        REQUIRE(cfg);
@@ -624,14 +626,14 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
        result = synthrecord_parseconfig(inst, parameters, cfg, cfgfile,
                                         cfgline, aclctx, ctx->origin);
 
-       hook = (ns_hook_t){ .action = synthrecord_entry, .action_data = inst };
-       ns_hook_add(hooktable, mctx, NS_QUERY_NXDOMAIN_BEGIN, &hook);
+       hook = (dns_hook_t){ .action = synthrecord_entry, .action_data = inst };
+       dns_hook_add(hooktable, mctx, NS_QUERY_NXDOMAIN_BEGIN, &hook);
 
        /*
         * The qname with a different type might be defined in the zone. If
         * there is a delegation, NS_QUERY_NODATA_BEGIN is never called.
         */
-       ns_hook_add(hooktable, mctx, NS_QUERY_NODATA_BEGIN, &hook);
+       dns_hook_add(hooktable, mctx, NS_QUERY_NODATA_BEGIN, &hook);
 
        return result;
 }
@@ -639,12 +641,12 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
 isc_result_t
 plugin_check(const char *parameters, const void *cfg, const char *cfgfile,
             unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
-            const ns_pluginctx_t *ctx) {
+            const dns_pluginctx_t *ctx) {
        isc_result_t result;
        synthrecord_t *inst = NULL;
 
        REQUIRE(ctx != NULL);
-       if (ctx->source != NS_HOOKSOURCE_ZONE || ctx->origin == NULL) {
+       if (ctx->source != DNS_HOOKSOURCE_ZONE || ctx->origin == NULL) {
                isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
                              ISC_LOG_INFO,
                              "'synthrecord' must be configured "
@@ -688,5 +690,5 @@ plugin_destroy(void **instp) {
 
 int
 plugin_version(void) {
-       return NS_PLUGIN_VERSION;
+       return DNS_PLUGIN_VERSION;
 }
index 376529e15e90ad7838346825e6c2400b7ba28122..2c8acbfa5522c962d6930219556ce7e6cd3cc114 100644 (file)
@@ -30,8 +30,9 @@
 #include <isc/types.h>
 #include <isc/util.h>
 
+#include <dns/hooks.h>
+
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/query.h>
 #include <ns/types.h>
 
@@ -49,7 +50,7 @@
  * accessible until the client object is detached.
  */
 typedef struct async_instance {
-       ns_plugin_t *module;
+       dns_plugin_t *module;
        isc_mem_t *mctx;
        isc_ht_t *ht;
        isc_mutex_t hlock;
@@ -57,46 +58,46 @@ typedef struct async_instance {
 
 typedef struct state {
        bool async;
-       ns_hook_resume_t *rev;
-       ns_hookpoint_t hookpoint;
+       dns_hook_resume_t *rev;
+       dns_hookpoint_t hookpoint;
        isc_result_t origresult;
 } state_t;
 
 /*
  * Forward declarations of functions referenced in install_hooks().
  */
-static ns_hookresult_t
+static dns_hookresult_t
 async_query_setup(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 async_query_done_begin(void *arg, void *cbdata, isc_result_t *resp);
-static ns_hookresult_t
+static dns_hookresult_t
 async_query_reset(void *arg, void *cbdata, isc_result_t *resp);
 
 /*%
  * Register the functions to be called at each hook point in 'hooktable', using
  * memory context 'mctx' for allocating copies of stack-allocated structures
- * passed to ns_hook_add().  Make sure 'inst' will be passed as the 'cbdata'
+ * passed to dns_hook_add().  Make sure 'inst' will be passed as the 'cbdata'
  * argument to every callback.
  */
 static void
-install_hooks(ns_hooktable_t *hooktable, isc_mem_t *mctx,
+install_hooks(dns_hooktable_t *hooktable, isc_mem_t *mctx,
              async_instance_t *inst) {
-       const ns_hook_t async_setup = {
+       const dns_hook_t async_setup = {
                .action = async_query_setup,
                .action_data = inst,
        };
-       const ns_hook_t async_donebegin = {
+       const dns_hook_t async_donebegin = {
                .action = async_query_done_begin,
                .action_data = inst,
        };
-       const ns_hook_t async_reset = {
+       const dns_hook_t async_reset = {
                .action = async_query_reset,
                .action_data = inst,
        };
 
-       ns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &async_setup);
-       ns_hook_add(hooktable, mctx, NS_QUERY_DONE_BEGIN, &async_donebegin);
-       ns_hook_add(hooktable, mctx, NS_QUERY_CLEANUP, &async_reset);
+       dns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &async_setup);
+       dns_hook_add(hooktable, mctx, NS_QUERY_DONE_BEGIN, &async_donebegin);
+       dns_hook_add(hooktable, mctx, NS_QUERY_CLEANUP, &async_reset);
 }
 
 static void
@@ -119,13 +120,13 @@ logmsg(const char *fmt, ...) {
 **/
 
 /*
- * Called by ns_plugin_register() to initialize the plugin and
+ * Called by dns_plugin_register() to initialize the plugin and
  * register hook functions into the view hook table.
  */
 isc_result_t
 plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
                unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
-               ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
+               dns_hooktable_t *hooktable, const dns_pluginctx_t *ctx,
                void **instp) {
        async_instance_t *inst = NULL;
 
@@ -158,7 +159,7 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
 isc_result_t
 plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
             unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
-            const ns_pluginctx_t *ctx) {
+            const dns_pluginctx_t *ctx) {
        UNUSED(parameters);
        UNUSED(cfg);
        UNUSED(cfg_file);
@@ -171,7 +172,7 @@ plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
 }
 
 /*
- * Called by ns_plugins_free(); frees memory allocated by
+ * Called by dns_plugins_free(); frees memory allocated by
  * the module when it was registered.
  */
 void
@@ -194,7 +195,7 @@ plugin_destroy(void **instp) {
  */
 int
 plugin_version(void) {
-       return NS_PLUGIN_VERSION;
+       return DNS_PLUGIN_VERSION;
 }
 
 static state_t *
@@ -243,7 +244,7 @@ client_state_destroy(const query_ctx_t *qctx, async_instance_t *inst) {
        isc_mem_put(inst->mctx, state, sizeof(*state));
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 async_query_setup(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        async_instance_t *inst = (async_instance_t *)cbdata;
@@ -257,18 +258,18 @@ async_query_setup(void *arg, void *cbdata, isc_result_t *resp) {
                client_state_create(qctx, inst);
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 static void
-cancelasync(ns_hookasync_t *hctx) {
+cancelasync(dns_hookasync_t *hctx) {
        UNUSED(hctx);
        logmsg("cancelasync");
 }
 
 static void
-destroyasync(ns_hookasync_t **ctxp) {
-       ns_hookasync_t *ctx = *ctxp;
+destroyasync(dns_hookasync_t **ctxp) {
+       dns_hookasync_t *ctx = *ctxp;
 
        logmsg("destroyasync");
        *ctxp = NULL;
@@ -277,23 +278,23 @@ destroyasync(ns_hookasync_t **ctxp) {
 
 static isc_result_t
 doasync(query_ctx_t *qctx, isc_mem_t *mctx, void *arg, isc_loop_t *loop,
-       isc_job_cb cb, void *evarg, ns_hookasync_t **ctxp) {
-       ns_hook_resume_t *rev = isc_mem_get(mctx, sizeof(*rev));
-       ns_hookasync_t *ctx = isc_mem_get(mctx, sizeof(*ctx));
+       isc_job_cb cb, void *evarg, dns_hookasync_t **ctxp) {
+       dns_hook_resume_t *rev = isc_mem_get(mctx, sizeof(*rev));
+       dns_hookasync_t *ctx = isc_mem_get(mctx, sizeof(*ctx));
        state_t *state = (state_t *)arg;
 
        logmsg("doasync");
-       *ctx = (ns_hookasync_t){
+       *ctx = (dns_hookasync_t){
                .cancel = cancelasync,
                .destroy = destroyasync,
        };
        isc_mem_attach(mctx, &ctx->mctx);
 
        qctx->result = DNS_R_NOTIMP;
-       *rev = (ns_hook_resume_t){
+       *rev = (dns_hook_resume_t){
                .hookpoint = state->hookpoint,
                .origresult = qctx->result,
-               .saved_qctx = qctx,
+               .context = qctx,
                .ctx = ctx,
                .arg = evarg,
        };
@@ -306,7 +307,7 @@ doasync(query_ctx_t *qctx, isc_mem_t *mctx, void *arg, isc_loop_t *loop,
        return ISC_R_SUCCESS;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 async_query_done_begin(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        async_instance_t *inst = (async_instance_t *)cbdata;
@@ -320,7 +321,7 @@ async_query_done_begin(void *arg, void *cbdata, isc_result_t *resp) {
        if (state->async) {
                /* resuming */
                state->async = false;
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 
        /* initial call */
@@ -328,10 +329,10 @@ async_query_done_begin(void *arg, void *cbdata, isc_result_t *resp) {
        state->hookpoint = NS_QUERY_DONE_BEGIN;
        state->origresult = *resp;
        ns_query_hookasync(qctx, doasync, state);
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 async_query_reset(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        async_instance_t *inst = (async_instance_t *)cbdata;
@@ -340,5 +341,5 @@ async_query_reset(void *arg, void *cbdata, isc_result_t *resp) {
        *resp = ISC_R_UNSET;
        client_state_destroy(qctx, inst);
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
index 5888e5b541c61bdf3189b30f6188aa580857fe54..e41e1845545c05153f5b115282ab36a910fee4c8 100644 (file)
  * information regarding copyright ownership.
  */
 
+#include <dns/hooks.h>
+
 #include <isccfg/aclconf.h>
 #include <isccfg/cfg.h>
 #include <isccfg/grammar.h>
 
-#include <ns/hooks.h>
+#include <ns/client.h>
+#include <ns/query.h>
 
 typedef struct {
        isc_mem_t *mctx;
@@ -36,7 +39,7 @@ typedef struct {
                }                              \
        } while (0)
 
-static ns_hookresult_t
+static dns_hookresult_t
 syncplugin__hook(void *arg, void *cbdata, isc_result_t *resp) {
        query_ctx_t *qctx = (query_ctx_t *)arg;
        syncplugin_t *inst = cbdata;
@@ -56,13 +59,13 @@ syncplugin__hook(void *arg, void *cbdata, isc_result_t *resp) {
                if (strncmp(inst->firstlbl, (char *)label.base + 1,
                            strlen(inst->firstlbl)) == 0)
                {
-                       return NS_HOOK_CONTINUE;
+                       return DNS_HOOK_CONTINUE;
                }
        }
 
        qctx->client->message->rcode = inst->rcode;
        *resp = ns_query_done(qctx);
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
 static cfg_clausedef_t syncplugin__cfgclauses[] = {
@@ -113,13 +116,13 @@ syncplugin__parse_rcode(const cfg_obj_t *syncplugincfg, uint8_t *rcode) {
 isc_result_t
 plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
                unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
-               ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
+               dns_hooktable_t *hooktable, const dns_pluginctx_t *ctx,
                void **instp) {
        isc_result_t result;
        cfg_obj_t *syncplugincfg = NULL;
        const cfg_obj_t *obj = NULL;
        isc_buffer_t b;
-       ns_hook_t hook;
+       dns_hook_t hook;
        syncplugin_t *inst = NULL;
        char *sourcestr = NULL;
        dns_name_t example2com = DNS_NAME_INITEMPTY;
@@ -155,7 +158,7 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
        sourcestr = obj->value.string.base;
 
        if (strcmp(sourcestr, "zone") == 0) {
-               if (ctx->source != NS_HOOKSOURCE_ZONE) {
+               if (ctx->source != DNS_HOOKSOURCE_ZONE) {
                        result = ISC_R_FAILURE;
                        goto cleanup;
                }
@@ -180,7 +183,7 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
                }
 
        } else if (strcmp(sourcestr, "view") == 0) {
-               if (ctx->source != NS_HOOKSOURCE_VIEW) {
+               if (ctx->source != DNS_HOOKSOURCE_VIEW) {
                        result = ISC_R_FAILURE;
                        goto cleanup;
                }
@@ -193,8 +196,8 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
                goto cleanup;
        }
 
-       hook = (ns_hook_t){ .action = syncplugin__hook, .action_data = inst };
-       ns_hook_add(hooktable, mctx, NS_QUERY_NXDOMAIN_BEGIN, &hook);
+       hook = (dns_hook_t){ .action = syncplugin__hook, .action_data = inst };
+       dns_hook_add(hooktable, mctx, NS_QUERY_NXDOMAIN_BEGIN, &hook);
 
 cleanup:
        if (dns_name_dynamic(&example2com)) {
@@ -219,7 +222,7 @@ cleanup:
 isc_result_t
 plugin_check(const char *parameters, const void *cfg, const char *cfgfile,
             unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
-            const ns_pluginctx_t *ctx) {
+            const dns_pluginctx_t *ctx) {
        UNUSED(parameters);
        UNUSED(cfg);
        UNUSED(cfgfile);
@@ -246,5 +249,5 @@ plugin_destroy(void **instp) {
 
 int
 plugin_version(void) {
-       return NS_PLUGIN_VERSION;
+       return DNS_PLUGIN_VERSION;
 }
similarity index 77%
rename from lib/ns/hooks.c
rename to lib/dns/hooks.c
index a851a23fb03c0ffeb18e810c13bb5003e22a2328..09bb5df26d4c630ff06fd4890ac53a480a10683e 100644 (file)
 #include <isc/util.h>
 #include <isc/uv.h>
 
-#include <dns/view.h>
-
-#include <ns/hooks.h>
-#include <ns/query.h>
+#include <dns/hooks.h>
 
 #define CHECK(op)                              \
        do {                                   \
                }                              \
        } while (0)
 
-struct ns_plugin {
+struct dns_plugin {
        isc_mem_t *mctx;
        uv_lib_t handle;
        void *inst;
        char *modpath;
-       ns_plugin_check_t *check_func;
-       ns_plugin_register_t *register_func;
-       ns_plugin_destroy_t *destroy_func;
-       ISC_LINK(ns_plugin_t) link;
+       dns_plugin_check_t *check_func;
+       dns_plugin_register_t *register_func;
+       dns_plugin_destroy_t *destroy_func;
+       ISC_LINK(dns_plugin_t) link;
 };
 
-static ns_hooklist_t default_hooktable[NS_HOOKPOINTS_COUNT];
-ns_hooktable_t *ns__hook_table = &default_hooktable;
+static dns_hooklist_t default_hooktable[DNS_HOOKPOINTS_COUNT];
+dns_hooktable_t *dns__hook_table = &default_hooktable;
 
 static isc_result_t
 plugin_expandpath(const char *src, char *dst, size_t dstsize, bool appendext) {
@@ -86,7 +83,7 @@ plugin_expandpath(const char *src, char *dst, size_t dstsize, bool appendext) {
 }
 
 isc_result_t
-ns_plugin_expandpath(const char *src, char *dst, size_t dstsize) {
+dns_plugin_expandpath(const char *src, char *dst, size_t dstsize) {
        isc_result_t result;
 
        result = plugin_expandpath(src, dst, dstsize, false);
@@ -130,20 +127,20 @@ load_symbol(uv_lib_t *handle, const char *modpath, const char *symbol_name,
 }
 
 static void
-unload_plugin(ns_plugin_t **pluginp);
+unload_plugin(dns_plugin_t **pluginp);
 
 static isc_result_t
-load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
+load_plugin(isc_mem_t *mctx, const char *modpath, dns_plugin_t **pluginp) {
        isc_result_t result;
-       ns_plugin_t *plugin = NULL;
-       ns_plugin_version_t *version_func = NULL;
+       dns_plugin_t *plugin = NULL;
+       dns_plugin_version_t *version_func = NULL;
        int version;
        int r;
 
        REQUIRE(pluginp != NULL && *pluginp == NULL);
 
        plugin = isc_mem_get(mctx, sizeof(*plugin));
-       *plugin = (ns_plugin_t){
+       *plugin = (dns_plugin_t){
                .modpath = isc_mem_strdup(mctx, modpath),
        };
 
@@ -168,13 +165,13 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
                          (void **)&version_func));
 
        version = version_func();
-       if (version < (NS_PLUGIN_VERSION - NS_PLUGIN_AGE) ||
-           version > NS_PLUGIN_VERSION)
+       if (version < (DNS_PLUGIN_VERSION - DNS_PLUGIN_AGE) ||
+           version > DNS_PLUGIN_VERSION)
        {
                isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
                              ISC_LOG_ERROR,
                              "plugin API version mismatch: %d/%d", version,
-                             NS_PLUGIN_VERSION);
+                             DNS_PLUGIN_VERSION);
                CHECK(ISC_R_FAILURE);
        }
 
@@ -200,8 +197,8 @@ cleanup:
 }
 
 static void
-unload_plugin(ns_plugin_t **pluginp) {
-       ns_plugin_t *plugin = NULL;
+unload_plugin(dns_plugin_t **pluginp) {
+       dns_plugin_t *plugin = NULL;
 
        REQUIRE(pluginp != NULL && *pluginp != NULL);
 
@@ -222,11 +219,12 @@ unload_plugin(ns_plugin_t **pluginp) {
 }
 
 isc_result_t
-ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
-                  const char *cfg_file, unsigned long cfg_line,
-                  isc_mem_t *mctx, void *aclctx, ns_hook_data_t *hookdata) {
+dns_plugin_register(const char *modpath, const char *parameters,
+                   const void *cfg, const char *cfg_file,
+                   unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
+                   dns_hook_data_t *hookdata) {
        isc_result_t result;
-       ns_plugin_t *plugin = NULL;
+       dns_plugin_t *plugin = NULL;
 
        REQUIRE(mctx != NULL);
        REQUIRE(hookdata != NULL);
@@ -239,7 +237,7 @@ ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
        isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS, ISC_LOG_INFO,
                      "registering plugin '%s'", modpath);
 
-       INSIST(hookdata->pluginctx.source != NS_HOOKSOURCE_UNDEFINED);
+       INSIST(hookdata->pluginctx.source != DNS_HOOKSOURCE_UNDEFINED);
 
        CHECK(plugin->check_func(parameters, cfg, cfg_file, cfg_line, mctx,
                                 aclctx, &hookdata->pluginctx));
@@ -258,11 +256,11 @@ cleanup:
 }
 
 isc_result_t
-ns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
-               const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
-               void *aclctx, const ns_pluginctx_t *ctx) {
+dns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
+                const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
+                void *aclctx, const dns_pluginctx_t *ctx) {
        isc_result_t result;
-       ns_plugin_t *plugin = NULL;
+       dns_plugin_t *plugin = NULL;
 
        CHECK(load_plugin(mctx, modpath, &plugin));
 
@@ -278,30 +276,30 @@ cleanup:
 }
 
 void
-ns_hooktable_init(ns_hooktable_t *hooktable) {
+dns_hooktable_init(dns_hooktable_t *hooktable) {
        int i;
 
-       for (i = 0; i < NS_HOOKPOINTS_COUNT; i++) {
+       for (i = 0; i < DNS_HOOKPOINTS_COUNT; i++) {
                ISC_LIST_INIT((*hooktable)[i]);
        }
 }
 
 void
-ns_hooktable_create(isc_mem_t *mctx, ns_hooktable_t **tablep) {
-       ns_hooktable_t *hooktable = NULL;
+dns_hooktable_create(isc_mem_t *mctx, dns_hooktable_t **tablep) {
+       dns_hooktable_t *hooktable = NULL;
 
        REQUIRE(tablep != NULL && *tablep == NULL);
 
        hooktable = isc_mem_get(mctx, sizeof(*hooktable));
 
-       ns_hooktable_init(hooktable);
+       dns_hooktable_init(hooktable);
 
        *tablep = hooktable;
 }
 
 void
-ns_hooktable_free(isc_mem_t *mctx, void **tablep) {
-       ns_hooktable_t *table = NULL;
+dns_hooktable_free(isc_mem_t *mctx, void **tablep) {
+       dns_hooktable_t *table = NULL;
        int i = 0;
 
        REQUIRE(tablep != NULL && *tablep != NULL);
@@ -309,7 +307,7 @@ ns_hooktable_free(isc_mem_t *mctx, void **tablep) {
        table = *tablep;
        *tablep = NULL;
 
-       for (i = 0; i < NS_HOOKPOINTS_COUNT; i++) {
+       for (i = 0; i < DNS_HOOKPOINTS_COUNT; i++) {
                ISC_LIST_FOREACH((*table)[i], hook, link) {
                        ISC_LIST_UNLINK((*table)[i], hook, link);
                        if (hook->mctx != NULL) {
@@ -323,17 +321,17 @@ ns_hooktable_free(isc_mem_t *mctx, void **tablep) {
 }
 
 void
-ns_hook_add(ns_hooktable_t *hooktable, isc_mem_t *mctx,
-           ns_hookpoint_t hookpoint, const ns_hook_t *hook) {
-       ns_hook_t *copy = NULL;
+dns_hook_add(dns_hooktable_t *hooktable, isc_mem_t *mctx,
+            dns_hookpoint_t hookpoint, const dns_hook_t *hook) {
+       dns_hook_t *copy = NULL;
 
        REQUIRE(hooktable != NULL);
        REQUIRE(mctx != NULL);
-       REQUIRE(hookpoint < NS_HOOKPOINTS_COUNT);
+       REQUIRE(hookpoint < DNS_HOOKPOINTS_COUNT);
        REQUIRE(hook != NULL);
 
        copy = isc_mem_get(mctx, sizeof(*copy));
-       *copy = (ns_hook_t){
+       *copy = (dns_hook_t){
                .action = hook->action,
                .action_data = hook->action_data,
        };
@@ -344,21 +342,21 @@ ns_hook_add(ns_hooktable_t *hooktable, isc_mem_t *mctx,
 }
 
 void
-ns_plugins_create(isc_mem_t *mctx, ns_plugins_t **listp) {
-       ns_plugins_t *plugins = NULL;
+dns_plugins_create(isc_mem_t *mctx, dns_plugins_t **listp) {
+       dns_plugins_t *plugins = NULL;
 
        REQUIRE(listp != NULL && *listp == NULL);
 
        plugins = isc_mem_get(mctx, sizeof(*plugins));
-       *plugins = (ns_plugins_t){ 0 };
+       *plugins = (dns_plugins_t){ 0 };
        ISC_LIST_INIT(*plugins);
 
        *listp = plugins;
 }
 
 void
-ns_plugins_free(isc_mem_t *mctx, void **listp) {
-       ns_plugins_t *list = NULL;
+dns_plugins_free(isc_mem_t *mctx, void **listp) {
+       dns_plugins_t *list = NULL;
 
        REQUIRE(listp != NULL && *listp != NULL);
 
similarity index 74%
rename from lib/ns/include/ns/hooks.h
rename to lib/dns/include/dns/hooks.h
index 4598c70de00c9664b66fb867dada109bb8f24cc8..bc18c445044a8267d14983b3fd60a8b871c23c05 100644 (file)
 #include <stdbool.h>
 
 #include <isc/list.h>
+#include <isc/loop.h>
 #include <isc/magic.h>
 #include <isc/mem.h>
 #include <isc/result.h>
 
-#include <dns/rdatatype.h>
+#include <dns/types.h>
 
-#include <ns/client.h>
-#include <ns/query.h>
 /*
  * "Hooks" are a mechanism to call a defined function or set of functions once
  * a certain place in code is reached.  Hook actions can inspect and alter the
  * where they are used to inspect state before and after certain functions have
  * run.
  *
- * Both of these uses are limited to libns, so hooks are currently defined in
- * the ns/hooks.h header file, and hook-related macro and function names are
- * prefixed with `NS_` and `ns_`.  However, the design is fairly generic and
- * could be repurposed for general use, e.g. as part of libisc, after some
- * further customization.
+ * While these uses are limited to libns, there are future plans to add
+ * hooks in dns_resolver, so hooks are defined in the dns/hooks.h header
+ * file, and hook-related macro and function names that aren't specifically
+ * related to ns/query.c are prefixed with `DNS_` and `dns_`.
  *
- * Hooks are created by defining a hook point identifier in the ns_hookpoint_t
+ * Hooks are created by defining a hook point identifier in the dns_hookpoint_t
  * enum below, and placing a special call at a corresponding location in the
  * code which invokes the action(s) for that hook; there are two such special
  * calls currently implemented, namely the CALL_HOOK() and CALL_HOOK_NORETURN()
  * Each view and zone has its own separate hook table, populated by loading
  * plugin modules specified in the "plugin" statements in named.conf. (See
  * `ZONE-SPECIFIC PLUGINS` section below.) There is also a special, global
- * hook table (ns__hook_table) that is only used by libns unit tests and
+ * hook table (dns__hook_table) that is only used by libns unit tests and
  * whose existence can be safely ignored by plugin modules.
  *
  * Hook actions are functions which:
  *
- *   - return ans_hookresult_t value:
- *       - if NS_HOOK_RETURN is returned by the hook action, the function
+ *   - return a dns_hookresult_t value:
+ *       - if DDNS_HOOK_RETURN is returned by the hook action, the function
  *         into which the hook is inserted will return and no further hook
  *         actions at the same hook point will be invoked,
- *       - if NS_HOOK_CONTINUE is returned by the hook action and there are
+ *       - if DDNS_HOOK_CONTINUE is returned by the hook action and there are
  *         further hook actions set up at the same hook point, they will be
- *         processed; if NS_HOOK_CONTINUE is returned and there are no
+ *         processed; if DDNS_HOOK_CONTINUE is returned and there are no
  *         further hook actions set up at the same hook point, execution of
  *         the function into which the hook has been inserted will be
  *         resumed.
  *       - a pointer specified upon inserting the action into the hook table,
  *       - a pointer to an isc_result_t value which will be returned by the
  *         function into which the hook is inserted if the action returns
- *         NS_HOOK_RETURN.
+ *         DDNS_HOOK_RETURN.
  *
  * In order for a hook action to be called for a given hook, a pointer to that
  * action function (along with an optional pointer to action-specific data) has
  * to be inserted into the relevant hook table entry for that hook using an
- * ns_hook_add() call.  If multiple actions are set up at a single hook point
+ * dns_hook_add() call.  If multiple actions are set up at a single hook point
  * (e.g. by multiple plugin modules), they are processed in FIFO order, that is
- * they are performed in the same order in which their relevant ns_hook_add()
+ * they are performed in the same order in which their relevant dns_hook_add()
  * calls were issued.  Since the configuration is loaded from a single thread,
  * this means that multiple actions at a single hook point are determined by
  * the order in which the relevant plugin modules were declared in the
  *
  *     CALL_HOOK(NS_QUERY_FOO_BEGIN, qctx);
  *
- *     ns_client_log(qctx->client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
+ *     dns_client_log(qctx->client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_QUERY,
  *                   ISC_LOG_DEBUG(99), "Lorem ipsum dolor sit amet...");
  *
  *     result = ISC_R_COMPLETE;
  * and the following hook action:
  *
  * ----------------------------------------------------------------------------
- * static ns_hookresult_t
+ * static dns_hookresult_t
  * cause_failure(void *hook_data, void *action_data, isc_result_t *resultp) {
  *     UNUSED(hook_data);
  *     UNUSED(action_data);
  *
  *     *resultp = ISC_R_FAILURE;
  *
- *     return (NS_HOOK_RETURN);
+ *     return (DDNS_HOOK_RETURN);
  * }
  * ----------------------------------------------------------------------------
  *
  * If this hook action was installed in the hook table using:
  *
  * ----------------------------------------------------------------------------
- * const ns_hook_t foo_fail = {
+ * const dns_hook_t foo_fail = {
  *     .action = cause_failure,
  * };
  *
- * ns_hook_add(..., NS_QUERY_FOO_BEGIN, &foo_fail);
+ * dns_hook_add(..., NS_QUERY_FOO_BEGIN, &foo_fail);
  * ----------------------------------------------------------------------------
  *
  * then query_foo() would return ISC_R_FAILURE every time it is called due
- * to the cause_failure() hook action returning NS_HOOK_RETURN and setting
+ * to the cause_failure() hook action returning DDNS_HOOK_RETURN and setting
  * '*resultp' to ISC_R_FAILURE.  query_foo() would also never log the
  * "Lorem ipsum dolor sit amet..." message.
  *
  * Consider a different hook action:
  *
  * ----------------------------------------------------------------------------
- * static ns_hookresult_t
+ * static dns_hookresult_t
  * log_qtype(void *hook_data, void *action_data, isc_result_t *resultp) {
  *     query_ctx_t *qctx = (query_ctx_t *)hook_data;
  *     FILE *stream = (FILE *)action_data;
  *
  *     fprintf(stream, "QTYPE=%u\n", qctx->qtype);
  *
- *     return (NS_HOOK_CONTINUE);
+ *     return (DDNS_HOOK_CONTINUE);
  * }
  * ----------------------------------------------------------------------------
  *
  * cause_failure(), using:
  *
  * ----------------------------------------------------------------------------
- * const ns_hook_t foo_log_qtype = {
+ * const dns_hook_t foo_log_qtype = {
  *     .action = log_qtype,
  *     .action_data = stderr,
  * };
  *
- * ns_hook_add(..., NS_QUERY_FOO_BEGIN, &foo_log_qtype);
+ * dns_hook_add(..., NS_QUERY_FOO_BEGIN, &foo_log_qtype);
  * ----------------------------------------------------------------------------
  *
  * then the QTYPE stored in the query context passed to query_foo() would be
  * logged to stderr upon each call to that function; 'qctx' would be passed to
  * the hook action in 'hook_data' since it is specified in the CALL_HOOK() call
  * inside query_foo() while stderr would be passed to the hook action in
- * 'action_data' since it is specified in the ns_hook_t structure passed to
- * ns_hook_add().  As the hook action returns NS_HOOK_CONTINUE,
+ * 'action_data' since it is specified in the dns_hook_t structure passed to
+ * dns_hook_add().  As the hook action returns DDNS_HOOK_CONTINUE,
  * query_foo() would also be logging the "Lorem ipsum dolor sit amet..."
  * message before returning ISC_R_COMPLETE.
  *
  * etc, it may take several seconds or more.
  *
  * In order to handle such a situation, a hook action can start an
- * asynchronous event by calling ns_query_hookasync().  This is similar
- * to ns_query_recurse(), but more generic.  ns_query_hookasync() will
+ * asynchronous event by calling dns_query_hookasync().  This is similar
+ * to dns_query_recurse(), but more generic.  dns_query_hookasync() will
  * call the 'runasync' function with a specified 'arg' (both passed to
- * ns_query_hookasync()) and a set of loop and associated event arguments
+ * dns_query_hookasync()) and a set of loop and associated event arguments
  * to be called to resume query handling upon completion of the
  * asynchronous event.
  *
  * The implementation of 'runasync' is assumed to allocate and build an
- * instance of ns_hook_resume_t whose callback, arg, and loop are set to
- * the passed values from ns_query_hookasync().  Other fields of
- * ns_hook_resume_t must be correctly set in the hook implementation
+ * instance of dns_hook_resume_t whose callback, arg, and loop are set to
+ * the passed values from dns_query_hookasync().  Other fields of
+ * dns_hook_resume_t must be correctly set in the hook implementation
  * by the time it's sent to the specified loop:
  *
  * - hookpoint: the point from which the query handling should be resumed
  * The hook implementation should somehow maintain the created event
  * instance so that it can eventually send the event.
  *
- * 'runasync' then creates an instance of ns_hookasync_t with specifying its
- * own cancel and destroy function, and returns it to ns_query_hookasync()
+ * 'runasync' then creates an instance of dns_hookasync_t with specifying its
+ * own cancel and destroy function, and returns it to dns_query_hookasync()
  * in the passed pointer.
  *
- * On return from ns_query_hookasync(), the hook action MUST return
- * NS_HOOK_RETURN to suspend the query handling.
+ * On return from dns_query_hookasync(), the hook action MUST return
+ * DDNS_HOOK_RETURN to suspend the query handling.
  *
  * On the completion of the asynchronous event, the hook implementation is
  * supposed to send the resumeevent to the corresponding loop.  The query
  *
  * typedef struct hookstate {
  *     bool async;
- *     ns_hook_resume_t *rev
- *     ns_hookpoint_t hookpoint;
+ *     dns_hook_resume_t *rev
+ *     dns_hookpoint_t hookpoint;
  *     isc_result_t origresult;
  * } hookstate_t;
  *
  *             // complete the hook's action using the result of the
  *             // internal asynchronous event.
  *             state->async = false;
- *             return (NS_HOOK_CONTINUE);
+ *             return (DDNS_HOOK_CONTINUE);
  *     }
  *
  *     // Initial call to the hook action.  Start the internal
  *     // asynchronous event, and have the query module suspend
- *     // its own handling by returning NS_HOOK_RETURN.
+ *     // its own handling by returning DDNS_HOOK_RETURN.
  *     state->hookpoint = ...; // would be hook point for this hook
  *     state->origresult = *resultp;
- *     ns_query_hookasync(hook_data, runasync, state);
+ *     dns_query_hookasync(hook_data, runasync, state);
  *     state->async = true;
- *     return (NS_HOOK_RETURN);
+ *     return (DDNS_HOOK_RETURN);
  * }
  *
  * And the 'runasync' function would be something like this:
  *
  * static isc_result_t
  * runasync(query_ctx_t *qctx, void *arg, isc_job_cb cb, void *evarg,
- *         isc_loop_t *loop, ns_hookasync_t **ctxp) {
+ *         isc_loop_t *loop, dns_hookasync_t **ctxp) {
  *     hookstate_t *state = arg;
- *     ns_hook_resume_t *rev isc_mem_get(mctx, sizeof(*rev));
- *     ns_hookasync_t *ctx = isc_mem_get(mctx, sizeof(*ctx));
- *
- *     *ctx = (ns_hookasync_t){ .private = NULL
- *                               .hookpoint = state->hookpoint,
- *                               .origresult = state->origresult,
- *                               .saved_ctx = qctx,
- *                               .ctx = ctx,
- *                               .loop = loop,
- *                               .cb = cb,
- *                               .arg = cbarg
+ *     dns_hook_resume_t *rev isc_mem_get(mctx, sizeof(*rev));
+ *     dns_hookasync_t *ctx = isc_mem_get(mctx, sizeof(*ctx));
+ *
+ *     *ctx = (dns_hookasync_t){ .private = NULL
+ *                                .hookpoint = state->hookpoint,
+ *                                .origresult = state->origresult,
+ *                                .saved_ctx = qctx,
+ *                                .ctx = ctx,
+ *                                .loop = loop,
+ *                                .cb = cb,
+ *                                .arg = cbarg
  *     };
  *     isc_mem_attach(mctx, &ctx->mctx);
  *
  *
  * - Zone plugin hooks are called first. Zone template hooks are called
  *   second. View hooks are called third. If any plugin hook at any level
- *   returns NS_HOOK_RETURN, the whole calling chain is stopped and no
- *   subsequent hooks are called. (See the `ns__query_hookchain` unit test
+ *   returns DDNS_HOOK_RETURN, the whole calling chain is stopped and no
+ *   subsequent hooks are called. (See the `dns__query_hookchain` unit test
  *   in `tests/ns/query_test.c`.)
  *
  * - When a query hook is called, the `qctx->client->query.authzone`
  *   pointer is checked to determine whether an authoritative zone is
  *   being used to answer the query; if so, the zone's hooktable is used to
  *   call the hooks. As a consequence, a zone plugin won't be called by all
- *   the hook points defined below in `ns_hookpoint_t`. For instance,
+ *   the hook points defined below in `dns_hookpoint_t`. For instance,
  *   `NS_QUERY_SETUP` and `NS_QUERY_QCTX_INITIALIZED` will never be
  *   called in a zone plugin, as they occur before the zone has been
  *   looked up.  `NS_QUERY_DONE_BEGIN` could be called if an
  *   instance, bad cookie handling), it would be skipped.
  *
  * The `plugin_register` function (defined by each plugin and called
- * when the plugin is loaded) has a `ns_pluginctx_t ctx` parameter.
+ * when the plugin is loaded) has a `dns_pluginctx_t ctx` parameter.
  * This provides to the plugin registering function various contextual
- * informations about the plugin. For instance,  the `ns_hooksource_t source`
+ * informations about the plugin. For instance,  the `dns_hooksource_t source`
  * property indicates whether the plugin has been loaded at the zone level
- * (`NS_HOOKSOURCE_ZONE`) or at the view level (`NS_HOOKSOURCE_VIEW`).
+ * (`DNS_HOOKSOURCE_ZONE`) or at the view level (`DNS_HOOKSOURCE_VIEW`).
  * While this can be ignored if it doesn't matter where the plugin is
  * loaded, it can also be checked to enforce that the plugin is loaded
  * only at the zone or view level. Another property is `dns_name_t *origin`
  * which indicates the zone name to the plugin if it is loaded at the zone level
- * (this property is NULL otherwise). Note that `ns_pluginctx_t`
+ * (this property is NULL otherwise). Note that `dns_pluginctx_t`
  * parameter is defined in a parent stack frame, thus, it is valid only during
  * `plugin_register` execution.
  */
  * order in which they are referenced in query.c.
  */
 typedef enum {
-       /* hookpoints from query.c */
+       /* hookpoints from ns/query.c */
        NS_QUERY_SETUP,
        NS_QUERY_CLEANUP,
        NS_QUERY_START_BEGIN,
@@ -420,45 +418,45 @@ typedef enum {
 
        /* XXX other files could be added later */
 
-       NS_HOOKPOINTS_COUNT /* MUST BE LAST */
-} ns_hookpoint_t;
+       DNS_HOOKPOINTS_COUNT /* MUST BE LAST */
+} dns_hookpoint_t;
 
 /*
  * Returned by a hook action to indicate how to proceed after it has
  * been called: continue processing, or return immediately.
  */
 typedef enum {
-       NS_HOOK_CONTINUE,
-       NS_HOOK_RETURN,
-} ns_hookresult_t;
+       DNS_HOOK_CONTINUE,
+       DNS_HOOK_RETURN,
+} dns_hookresult_t;
 
-typedef ns_hookresult_t (*ns_hook_action_t)(void *arg, void *data,
-                                           isc_result_t *resultp);
+typedef dns_hookresult_t (*dns_hook_action_t)(void *arg, void *data,
+                                             isc_result_t *resultp);
 
-typedef struct ns_hook {
-       isc_mem_t       *mctx;
-       ns_hook_action_t action;
-       void            *action_data;
-       ISC_LINK(struct ns_hook) link;
-} ns_hook_t;
+typedef struct dns_hook {
+       isc_mem_t        *mctx;
+       dns_hook_action_t action;
+       void             *action_data;
+       ISC_LINK(struct dns_hook) link;
+} dns_hook_t;
 
-typedef ISC_LIST(ns_hook_t) ns_hooklist_t;
-typedef ns_hooklist_t ns_hooktable_t[NS_HOOKPOINTS_COUNT];
+typedef ISC_LIST(dns_hook_t) dns_hooklist_t;
+typedef dns_hooklist_t dns_hooktable_t[DNS_HOOKPOINTS_COUNT];
 
 /*%
- * ns__hook_table is a global hook table, which is used if view->hooktable
+ * dns__hook_table is a global hook table, which is used if view->hooktable
  * is NULL.  It's intended only for use by unit tests.
  */
-extern ns_hooktable_t *ns__hook_table;
+extern dns_hooktable_t *dns__hook_table;
 
-typedef void (*ns_hook_cancelasync_t)(ns_hookasync_t *);
-typedef void (*ns_hook_destroyasync_t)(ns_hookasync_t **);
+typedef void (*dns_hook_cancelasync_t)(dns_hookasync_t *);
+typedef void (*dns_hook_destroyasync_t)(dns_hookasync_t **);
 
 /*%
  * Context for a hook-initiated asynchronous process. This works
  * similarly to dns_fetch_t.
  */
-struct ns_hookasync {
+struct dns_hookasync {
        isc_mem_t *mctx;
 
        /*
@@ -466,8 +464,8 @@ struct ns_hookasync {
         * dns_resolver_destroyfetch, respectively, but specified as function
         * pointers since they can be hook-specific.
         */
-       ns_hook_cancelasync_t  cancel;
-       ns_hook_destroyasync_t destroy;
+       dns_hook_cancelasync_t  cancel;
+       dns_hook_destroyasync_t destroy;
 
        void *private; /* hook-specific data */
 };
@@ -476,58 +474,58 @@ struct ns_hookasync {
  * isc_event to be sent on the completion of a hook-initiated asyncronous
  * process, similar to dns_fetchresponse_t.
  */
-typedef struct ns_hook_resume {
-       ns_hookasync_t *ctx;       /* asynchronous processing context */
-       ns_hookpoint_t  hookpoint; /* hook point from which to resume */
+typedef struct dns_hook_resume {
+       dns_hookasync_t *ctx;       /* asynchronous processing context */
+       dns_hookpoint_t  hookpoint; /* hook point from which to resume */
        isc_result_t origresult; /* result code at the point of call to hook */
-       query_ctx_t *saved_qctx; /* qctx at the point of call to hook */
+       void        *context;    /* context and the point of call to hook */
        isc_loop_t  *loop;       /* loopmgr loop to resume in */
        isc_job_cb   cb;         /* callback function */
        void        *arg;        /* argument to pass to the callback */
-} ns_hook_resume_t;
+} dns_hook_resume_t;
 
 /*
  * Wrapper struct holding hook/plugins owning data structures used and owned by
  * zones and views having registered plugins.
  */
 typedef enum {
-       NS_HOOKSOURCE_UNDEFINED,
-       NS_HOOKSOURCE_VIEW,
-       NS_HOOKSOURCE_ZONE
-} ns_hooksource_t;
+       DNS_HOOKSOURCE_UNDEFINED,
+       DNS_HOOKSOURCE_VIEW,
+       DNS_HOOKSOURCE_ZONE
+} dns_hooksource_t;
 
-typedef struct ns_pluginctx {
+typedef struct dns_pluginctx {
        /* is this a zone or a view plugin */
-       ns_hooksource_t source;
+       dns_hooksource_t source;
 
        /* origin of the zone if this is a zone plugin, NULL otherwise */
        const dns_name_t *origin;
-} ns_pluginctx_t;
+} dns_pluginctx_t;
 
-typedef struct ns_hook_data {
-       ns_hooktable_t *hooktable;
-       ns_plugins_t   *plugins;
-       ns_pluginctx_t  pluginctx;
-} ns_hook_data_t;
+typedef struct dns_hook_data {
+       dns_hooktable_t *hooktable;
+       dns_plugins_t   *plugins;
+       dns_pluginctx_t  pluginctx;
+} dns_hook_data_t;
 
 /*
  * Plugin API version
  *
- * When the API changes, increment NS_PLUGIN_VERSION. If the
+ * When the API changes, increment DNS_PLUGIN_VERSION. If the
  * change is backward-compatible (e.g., adding a new function call
- * but not changing or removing an old one), increment NS_PLUGIN_AGE
- * as well; if not, set NS_PLUGIN_AGE to 0.
+ * but not changing or removing an old one), increment DNS_PLUGIN_AGE
+ * as well; if not, set DNS_PLUGIN_AGE to 0.
  */
-#ifndef NS_PLUGIN_VERSION
-#define NS_PLUGIN_VERSION 3
-#define NS_PLUGIN_AGE    0
-#endif /* ifndef NS_PLUGIN_VERSION */
+#ifndef DNS_PLUGIN_VERSION
+#define DNS_PLUGIN_VERSION 3
+#define DNS_PLUGIN_AGE    0
+#endif /* ifndef DNS_PLUGIN_VERSION */
 
 typedef isc_result_t
-ns_plugin_register_t(const char *parameters, const void *cfg, const char *file,
-                    unsigned long line, isc_mem_t *mctx, void *aclctx,
-                    ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
-                    void **instp);
+dns_plugin_register_t(const char *parameters, const void *cfg, const char *file,
+                     unsigned long line, isc_mem_t *mctx, void *aclctx,
+                     dns_hooktable_t *hooktable, const dns_pluginctx_t *ctx,
+                     void **instp);
 /*%<
  * Called when registering a new plugin.
  *
@@ -542,7 +540,7 @@ ns_plugin_register_t(const char *parameters, const void *cfg, const char *file,
  */
 
 typedef void
-ns_plugin_destroy_t(void **instp);
+dns_plugin_destroy_t(void **instp);
 /*%<
  * Destroy a plugin instance.
  *
@@ -550,33 +548,33 @@ ns_plugin_destroy_t(void **instp);
  */
 
 typedef isc_result_t
-ns_plugin_check_t(const char *parameters, const void *cfg, const char *file,
-                 unsigned long line, isc_mem_t *mctx, void *aclctx,
-                 const ns_pluginctx_t *ctx);
+dns_plugin_check_t(const char *parameters, const void *cfg, const char *file,
+                  unsigned long line, isc_mem_t *mctx, void *aclctx,
+                  const dns_pluginctx_t *ctx);
 /*%<
  * Check the validity of 'parameters'.
  */
 
 typedef int
-ns_plugin_version_t(void);
+dns_plugin_version_t(void);
 /*%<
  * Return the API version number a plugin was compiled with.
  *
  * If the returned version number is no greater than
- * NS_PLUGIN_VERSION, and no less than NS_PLUGIN_VERSION - NS_PLUGIN_AGE,
+ * DNS_PLUGIN_VERSION, and no less than DNS_PLUGIN_VERSION - DNS_PLUGIN_AGE,
  * then the module is API-compatible with named.
  */
 
 /*%
  * Prototypes for API functions to be defined in each module.
  */
-ns_plugin_check_t    plugin_check;
-ns_plugin_destroy_t  plugin_destroy;
-ns_plugin_register_t plugin_register;
-ns_plugin_version_t  plugin_version;
+dns_plugin_check_t    plugin_check;
+dns_plugin_destroy_t  plugin_destroy;
+dns_plugin_register_t plugin_register;
+dns_plugin_version_t  plugin_version;
 
 isc_result_t
-ns_plugin_expandpath(const char *src, char *dst, size_t dstsize);
+dns_plugin_expandpath(const char *src, char *dst, size_t dstsize);
 /*%<
  * Prepare the plugin location to be passed to dlopen() based on the plugin
  * path or filename found in the configuration file ('src').  Store the result
@@ -598,9 +596,10 @@ ns_plugin_expandpath(const char *src, char *dst, size_t dstsize);
  */
 
 isc_result_t
-ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
-                  const char *cfg_file, unsigned long cfg_line,
-                  isc_mem_t *mctx, void *aclctx, ns_hook_data_t *hookdata);
+dns_plugin_register(const char *modpath, const char *parameters,
+                   const void *cfg, const char *cfg_file,
+                   unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
+                   dns_hook_data_t *hookdata);
 /*%<
  * Load the plugin module specified from the file 'modpath', and
  * register an instance using 'parameters'.
@@ -617,9 +616,9 @@ ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
  */
 
 isc_result_t
-ns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
-               const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
-               void *aclctx, const ns_pluginctx_t *ctx);
+dns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
+                const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
+                void *aclctx, const dns_pluginctx_t *ctx);
 /*%<
  * Open the plugin module at 'modpath' and check the validity of
  * 'parameters', logging any errors or warnings found, then
@@ -627,26 +626,26 @@ ns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
  */
 
 void
-ns_plugins_create(isc_mem_t *mctx, ns_plugins_t **listp);
+dns_plugins_create(isc_mem_t *mctx, dns_plugins_t **listp);
 /*%<
  * Create and initialize a plugin list.
  */
 
 void
-ns_plugins_free(isc_mem_t *mctx, void **listp);
+dns_plugins_free(isc_mem_t *mctx, void **listp);
 /*%<
  * Close each plugin module in a plugin list, then free the list object.
  */
 
 void
-ns_hooktable_free(isc_mem_t *mctx, void **tablep);
+dns_hooktable_free(isc_mem_t *mctx, void **tablep);
 /*%<
  * Free a hook table.
  */
 
 void
-ns_hook_add(ns_hooktable_t *hooktable, isc_mem_t *mctx,
-           ns_hookpoint_t hookpoint, const ns_hook_t *hook);
+dns_hook_add(dns_hooktable_t *hooktable, isc_mem_t *mctx,
+            dns_hookpoint_t hookpoint, const dns_hook_t *hook);
 /*%<
  * Allocate (using memory context 'mctx') a copy of the 'hook' structure
  * describing a hook action and append it to the list of hooks at 'hookpoint'
@@ -663,13 +662,13 @@ ns_hook_add(ns_hooktable_t *hooktable, isc_mem_t *mctx,
  */
 
 void
-ns_hooktable_init(ns_hooktable_t *hooktable);
+dns_hooktable_init(dns_hooktable_t *hooktable);
 /*%<
  * Initialize a hook table.
  */
 
 void
-ns_hooktable_create(isc_mem_t *mctx, ns_hooktable_t **tablep);
+dns_hooktable_create(isc_mem_t *mctx, dns_hooktable_t **tablep);
 /*%<
  * Allocate and initialize a hook table.
  */
index 81dc8f95e23e061ef49d8a247c491bbe1fa8bf9e..12cb2e4badf436c2117d6c31dd00b71e9f1428c8 100644 (file)
@@ -96,6 +96,7 @@ typedef struct dns_fwdtable      dns_fwdtable_t;
 typedef struct dns_geoip_databases dns_geoip_databases_t;
 typedef struct dns_glue                   dns_glue_t;
 typedef struct dns_gluelist       dns_gluelist_t;
+typedef struct dns_hookasync      dns_hookasync_t;
 typedef struct dns_iptable        dns_iptable_t;
 typedef uint32_t                  dns_iterations_t;
 typedef struct dns_kasp                   dns_kasp_t;
@@ -124,12 +125,14 @@ typedef ISC_LIST(dns_name_t) dns_namelist_t;
 typedef struct dns_notify    dns_notify_t;
 typedef struct dns_notifyctx dns_notifyctx_t;
 typedef ISC_LIST(dns_notify_t) dns_notifylist_t;
-typedef struct dns_ntatable        dns_ntatable_t;
-typedef struct dns_ntnode          dns_ntnode_t;
-typedef enum dns_opcode                    dns_opcode_t;
-typedef struct dns_order           dns_order_t;
-typedef struct dns_peer                    dns_peer_t;
-typedef struct dns_peerlist        dns_peerlist_t;
+typedef struct dns_ntatable dns_ntatable_t;
+typedef struct dns_ntnode   dns_ntnode_t;
+typedef enum dns_opcode            dns_opcode_t;
+typedef struct dns_order    dns_order_t;
+typedef struct dns_peer            dns_peer_t;
+typedef struct dns_peerlist dns_peerlist_t;
+typedef struct dns_plugin   dns_plugin_t;
+typedef ISC_LIST(dns_plugin_t) dns_plugins_t;
 typedef struct dns_slabheader_proof dns_slabheader_proof_t;
 typedef struct dns_rbt             dns_rbt_t;
 typedef struct dns_rbtdb           dns_rbtdb_t;
index 1c3bbdb06e35a50428a768e80f036d21243eef32..bb74c0a2c637b05bd8eb143301e0f3a5666614c8 100644 (file)
@@ -243,7 +243,7 @@ struct dns_view {
        void (*plugins_free)(isc_mem_t *, void **);
 
        /* Hook table */
-       void *hooktable; /* ns_hooktable */
+       void *hooktable; /* dns_hooktable */
        void (*hooktable_free)(isc_mem_t *, void **);
 };
 
index f6628079d6f71a4a2189f2dae4335424cba5e33d..abd577efdd513c11319737c0c3b9d4ba533f3ac4 100644 (file)
@@ -104,6 +104,7 @@ dns_srcset.add(
         'forward.c',
         'gssapictx.c',
         'hmac_link.c',
+        'hooks.c',
         'ipkeylist.c',
         'iptable.c',
         'journal.c',
index f8c169745790d5663a3c4d5b8c855282dc22c806..390c05eba3dbc8ec9c6ed55927607a97953b1baa 100644 (file)
@@ -33,6 +33,7 @@
 #include <isc/md.h>
 #include <isc/mem.h>
 #include <isc/netaddr.h>
+#include <isc/netmgr.h>
 #include <isc/parseint.h>
 #include <isc/region.h>
 #include <isc/result.h>
@@ -45,6 +46,7 @@
 #include <dns/acl.h>
 #include <dns/dnstap.h>
 #include <dns/fixedname.h>
+#include <dns/hooks.h>
 #include <dns/journal.h>
 #include <dns/kasp.h>
 #include <dns/keymgr.h>
@@ -67,8 +69,6 @@
 #include <isccfg/kaspconf.h>
 #include <isccfg/namedconf.h>
 
-#include <ns/hooks.h>
-
 #define NAMED_CONTROL_PORT 953
 
 static in_port_t dnsport = 53;
@@ -3092,9 +3092,9 @@ check:
 struct check_one_plugin_data {
        isc_mem_t *mctx;
        cfg_aclconfctx_t *aclctx;
-       ns_hooksource_t source;
+       dns_hooksource_t source;
        isc_result_t *check_result;
-       const ns_pluginctx_t *ctx;
+       const dns_pluginctx_t *ctx;
 };
 
 /*%
@@ -3114,8 +3114,8 @@ check_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
 
        UNUSED(aclctx);
 
-       result = ns_plugin_expandpath(plugin_path, full_path,
-                                     sizeof(full_path));
+       result = dns_plugin_expandpath(plugin_path, full_path,
+                                      sizeof(full_path));
        if (result != ISC_R_SUCCESS) {
                cfg_obj_log(obj, ISC_LOG_ERROR,
                            "%s: plugin check failed: "
@@ -3124,9 +3124,9 @@ check_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
                return result;
        }
 
-       result = ns_plugin_check(full_path, parameters, config,
-                                cfg_obj_file(obj), cfg_obj_line(obj),
-                                data->mctx, data->aclctx, data->ctx);
+       result = dns_plugin_check(full_path, parameters, config,
+                                 cfg_obj_file(obj), cfg_obj_line(obj),
+                                 data->mctx, data->aclctx, data->ctx);
        if (result != ISC_R_SUCCESS) {
                cfg_obj_log(obj, ISC_LOG_ERROR, "%s: plugin check failed: %s",
                            full_path, isc_result_totext(result));
@@ -3141,9 +3141,9 @@ check_plugins(const cfg_obj_t *plugins, const cfg_obj_t *config,
              cfg_aclconfctx_t *aclctx, const dns_name_t *zname,
              isc_mem_t *mctx) {
        isc_result_t result = ISC_R_SUCCESS;
-       ns_pluginctx_t ctx = {
-               .source = (zname == NULL) ? NS_HOOKSOURCE_VIEW
-                                         : NS_HOOKSOURCE_ZONE,
+       dns_pluginctx_t ctx = {
+               .source = (zname == NULL) ? DNS_HOOKSOURCE_VIEW
+                                         : DNS_HOOKSOURCE_ZONE,
                .origin = zname,
        };
        struct check_one_plugin_data check_one_plugin_data = {
index c336c80dcae0f9f9cd6aa54fe74daa885fb9b4a2..dabe31b158db11833dccf1e480f29461ecf3f567 100644 (file)
@@ -118,7 +118,7 @@ struct ns_query {
        bool             authdbset;
        bool             isreferral;
        isc_mutex_t      fetchlock;
-       ns_hookasync_t  *hookasyncctx;
+       dns_hookasync_t *hookasyncctx;
        dns_rpz_st_t    *rpz_st;
        isc_bufferlist_t namebufs;
        ISC_LIST(ns_dbversion_t) activeversions;
@@ -241,7 +241,7 @@ typedef isc_result_t (*ns_query_starthookasync_t)(query_ctx_t *qctx,
                                                  isc_mem_t *mctx, void *arg,
                                                  isc_loop_t *loop,
                                                  isc_job_cb cb, void *evarg,
-                                                 ns_hookasync_t **ctxp);
+                                                 dns_hookasync_t **ctxp);
 
 /*
  * The following functions are expected to be used only within query.c
index d25060b6c81d37c36efa998f4e92a67c03788f92..8fdb8081c0652013d45af0538239e00fd467211a 100644 (file)
 
 typedef struct ns_altsecret ns_altsecret_t;
 typedef ISC_LIST(ns_altsecret_t) ns_altsecretlist_t;
-typedef struct ns_client    ns_client_t;
-typedef struct ns_clientmgr ns_clientmgr_t;
-typedef struct ns_plugin    ns_plugin_t;
-typedef ISC_LIST(ns_plugin_t) ns_plugins_t;
+typedef struct ns_client       ns_client_t;
+typedef struct ns_clientmgr    ns_clientmgr_t;
 typedef struct ns_interface    ns_interface_t;
 typedef struct ns_interfacemgr ns_interfacemgr_t;
 typedef struct ns_query               ns_query_t;
 typedef struct ns_server       ns_server_t;
 typedef struct ns_stats               ns_stats_t;
-typedef struct ns_hookasync    ns_hookasync_t;
 
 typedef enum { ns_cookiealg_siphash24 } ns_cookiealg_t;
 
index ded81571ec7cdf1f86e31faf98fb751aa0b37d38..739bf7295143eb69e1674d3ec36bc63ea2f3b655 100644 (file)
@@ -46,7 +46,6 @@ ns_srcset.add(
 ns_srcset.add(
     files(
         'client.c',
-        'hooks.c',
         'interfacemgr.c',
         'listenlist.c',
         'notify.c',
index 3e7e37d56e5d3686df6a8ca6d9d05cc1bdbe523c..91bc547e449c41908018b0d5fadd7bbc32170506 100644 (file)
@@ -45,6 +45,7 @@
 #include <dns/dns64.h>
 #include <dns/dnssec.h>
 #include <dns/ede.h>
+#include <dns/hooks.h>
 #include <dns/keytable.h>
 #include <dns/message.h>
 #include <dns/ncache.h>
@@ -69,7 +70,6 @@
 #include <dns/zt.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/interfacemgr.h>
 #include <ns/server.h>
 #include <ns/stats.h>
@@ -259,40 +259,40 @@ acquire_recursionquota(ns_client_t *client);
 static void
 release_recursionquota(ns_client_t *client);
 
-static inline ns_hookresult_t
+static inline dns_hookresult_t
 ns__query_callhook(uint8_t id, query_ctx_t *qctx, isc_result_t *result,
-                  ns_hooktable_t *hooktab) {
+                  dns_hooktable_t *hooktab) {
        isc_result_t hookresult = *result;
-       ns_hook_t *hook = ISC_LIST_HEAD((*hooktab)[id]);
+       dns_hook_t *hook = ISC_LIST_HEAD((*hooktab)[id]);
 
        while (hook != NULL) {
-               ns_hook_action_t func = hook->action;
+               dns_hook_action_t func = hook->action;
                void *data = hook->action_data;
 
                INSIST(func != NULL);
 
                switch (func(qctx, data, &hookresult)) {
-               case NS_HOOK_CONTINUE:
+               case DNS_HOOK_CONTINUE:
                        hook = ISC_LIST_NEXT(hook, link);
                        break;
-               case NS_HOOK_RETURN:
+               case DNS_HOOK_RETURN:
                        *result = hookresult;
-                       return NS_HOOK_RETURN;
+                       return DNS_HOOK_RETURN;
                default:
                        UNREACHABLE();
                }
        }
 
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 static inline void
 ns__query_callhook_noreturn(uint8_t id, query_ctx_t *qctx,
-                           ns_hooktable_t *hooktab) {
-       ns_hook_t *hook = ISC_LIST_HEAD((*hooktab)[id]);
+                           dns_hooktable_t *hooktab) {
+       dns_hook_t *hook = ISC_LIST_HEAD((*hooktab)[id]);
 
        while (hook != NULL) {
-               ns_hook_action_t func = hook->action;
+               dns_hook_action_t func = hook->action;
                void *data = hook->action_data;
                isc_result_t dummyres;
 
@@ -305,7 +305,7 @@ ns__query_callhook_noreturn(uint8_t id, query_ctx_t *qctx,
 
 /*
  * Call the specified hook function in every configured module that
- * implements that function. If any hook function returns NS_HOOK_RETURN,
+ * implements that function. If any hook function returns DNS_HOOK_RETURN,
  * we set 'result' and terminate processing by jumping to the 'cleanup' tag.
  *
  * Before any hook point is reached, qctx->view must be initialized to
@@ -316,24 +316,24 @@ ns__query_callhook_noreturn(uint8_t id, query_ctx_t *qctx,
  * is a macro instead of a static function; it needs to be able to use
  * 'goto cleanup' regardless of the return value.
  */
-#define CALL_HOOK(_id, _qctx)                                               \
-       if ((_qctx)->zhooks != NULL &&                                      \
-           ns__query_callhook(_id, _qctx, &result, (_qctx)->zhooks) ==     \
-                   NS_HOOK_RETURN)                                         \
-       {                                                                   \
-               goto cleanup;                                               \
-       }                                                                   \
-       if ((_qctx)->view->hooktable != NULL &&                             \
-           ns__query_callhook(_id, _qctx, &result,                         \
-                              (_qctx)->view->hooktable) == NS_HOOK_RETURN) \
-       {                                                                   \
-               goto cleanup;                                               \
-       }                                                                   \
-       if (ns__hook_table != NULL &&                                       \
-           ns__query_callhook(_id, _qctx, &result, ns__hook_table) ==      \
-                   NS_HOOK_RETURN)                                         \
-       {                                                                   \
-               goto cleanup;                                               \
+#define CALL_HOOK(_id, _qctx)                                                \
+       if ((_qctx)->zhooks != NULL &&                                       \
+           ns__query_callhook(_id, _qctx, &result, (_qctx)->zhooks) ==      \
+                   DNS_HOOK_RETURN)                                         \
+       {                                                                    \
+               goto cleanup;                                                \
+       }                                                                    \
+       if ((_qctx)->view->hooktable != NULL &&                              \
+           ns__query_callhook(_id, _qctx, &result,                          \
+                              (_qctx)->view->hooktable) == DNS_HOOK_RETURN) \
+       {                                                                    \
+               goto cleanup;                                                \
+       }                                                                    \
+       if (dns__hook_table != NULL &&                                       \
+           ns__query_callhook(_id, _qctx, &result, dns__hook_table) ==      \
+                   DNS_HOOK_RETURN)                                         \
+       {                                                                    \
+               goto cleanup;                                                \
        }
 
 /*
@@ -356,8 +356,8 @@ ns__query_callhook_noreturn(uint8_t id, query_ctx_t *qctx,
                ns__query_callhook_noreturn(_id, _qctx,                   \
                                            (_qctx)->view->hooktable);    \
        }                                                                 \
-       if (ns__hook_table != NULL) {                                     \
-               ns__query_callhook_noreturn(_id, _qctx, ns__hook_table);  \
+       if (dns__hook_table != NULL) {                                    \
+               ns__query_callhook_noreturn(_id, _qctx, dns__hook_table); \
        }
 
 /*
@@ -6613,10 +6613,10 @@ cleanup:
 
 static void
 query_hookresume(void *arg) {
-       ns_hook_resume_t *rev = (ns_hook_resume_t *)arg;
-       ns_hookasync_t *hctx = NULL;
+       dns_hook_resume_t *rev = (dns_hook_resume_t *)arg;
+       dns_hookasync_t *hctx = NULL;
        ns_client_t *client = rev->arg;
-       query_ctx_t *qctx = rev->saved_qctx;
+       query_ctx_t *qctx = rev->context;
        bool canceled;
 
        CTRACE(ISC_LOG_DEBUG(3), "query_hookresume");
@@ -6744,7 +6744,7 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync,
                   void *arg) {
        isc_result_t result;
        ns_client_t *client = qctx->client;
-       query_ctx_t *saved_qctx = NULL;
+       query_ctx_t *context = NULL;
 
        CTRACE(ISC_LOG_DEBUG(3), "ns_query_hookasync");
 
@@ -6757,8 +6757,8 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync,
                goto cleanup;
        }
 
-       qctx_save(qctx, &saved_qctx);
-       result = runasync(saved_qctx, client->manager->mctx, arg,
+       qctx_save(qctx, &context);
+       result = runasync(context, client->manager->mctx, arg,
                          client->manager->loop, query_hookresume, client,
                          &client->query.hookasyncctx);
        if (result != ISC_R_SUCCESS) {
@@ -6771,7 +6771,7 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync,
        /*
         * Typically the runasync() function will trigger recursion, but
         * there is no need to set NS_QUERYATTR_RECURSING. The calling hook
-        * is expected to return NS_HOOK_RETURN, and the RECURSING
+        * is expected to return DNS_HOOK_RETURN, and the RECURSING
         * attribute won't be checked anywhere.
         *
         * Hook-based asynchronous processing cannot coincide with normal
@@ -6798,10 +6798,10 @@ cleanup:
         * simply return on failure of this function, so there's no other
         * place for this to prevent leak.
         */
-       if (saved_qctx != NULL) {
-               qctx_clean(saved_qctx);
-               qctx_freedata(saved_qctx);
-               qctx_destroy(saved_qctx);
+       if (context != NULL) {
+               qctx_clean(context);
+               qctx_freedata(context);
+               qctx_destroy(context);
        }
        return result;
 }
@@ -11338,13 +11338,13 @@ ns_query_done(query_ctx_t *qctx) {
                if (qctx->client->query.restarts <
                    qctx->client->inner.view->max_restarts)
                {
-                       query_ctx_t *saved_qctx = NULL;
+                       query_ctx_t *context = NULL;
                        qctx->client->query.restarts++;
-                       qctx_save(qctx, &saved_qctx);
+                       qctx_save(qctx, &context);
                        isc_nmhandle_attach(qctx->client->inner.handle,
                                            &qctx->client->inner.restarthandle);
                        isc_async_run(qctx->client->manager->loop,
-                                     async_restart, saved_qctx);
+                                     async_restart, context);
                        return DNS_R_CONTINUE;
                } else {
                        /*
@@ -11444,7 +11444,7 @@ cleanup:
        /*
         * We'd only get here if one of the hooks above
         * (NS_QUERY_DONE_BEGIN or NS_QUERY_DONE_SEND) returned
-        * NS_HOOK_RETURN. Some housekeeping may be needed.
+        * DNS_HOOK_RETURN. Some housekeeping may be needed.
         */
        qctx_clean(qctx);
        qctx_freedata(qctx);
index 8d765013a8ed0fcf19ed0340e5e580eded504d6b..08364e3c062a1c4bece211ae7a63b614412ab150 100644 (file)
@@ -28,6 +28,7 @@ dns_tests = [
     'nsec3',
     'nsec3param',
     'private',
+    'plugin',
     'qp',
     'qpdb',
     'qpmulti',
similarity index 70%
rename from tests/ns/plugin_test.c
rename to tests/dns/plugin_test.c
index ecd239ad7b6b665360d798d0dbe2edff987c926a..480817f3ed10683671e7918e3278faaa9f4b9a57 100644 (file)
 #include <isc/types.h>
 #include <isc/util.h>
 
+#include <dns/hooks.h>
 #include <dns/lib.h>
 
+#include <tests/dns.h>
+
 /*
  * Mocking isc_file_exists() as it's used inside the tested
- * ns_plugin_expandpath() function defined in lib/ns/hooks.c
+ * dns_plugin_expandpath() function defined in lib/dns/hooks.c
  */
 static bool
 isc_file_exists(const char *pathname) {
@@ -44,28 +47,26 @@ isc_file_exists(const char *pathname) {
        return mock();
 }
 
-#include "../ns/hooks.c"
-
-#include <tests/ns.h>
+#include "../../dns/hooks.c"
 
 /*%
  * Structure containing parameters for run_full_path_test().
  */
 typedef struct {
-       const ns_test_id_t id; /* libns test identifier */
-       const char *input;     /* source string - plugin name or path */
-       bool exists;           /* return of mocked isc_file_exists() */
-       size_t output_size;    /* size of target char array to
-                               * allocate */
-       isc_result_t result;   /* expected return value */
-       const char *output;    /* expected output string */
-} ns_plugin_expandpath_test_params_t;
+       const dns_test_id_t id; /* libns test identifier */
+       const char *input;      /* source string - plugin name or path */
+       bool exists;            /* return of mocked isc_file_exists() */
+       size_t output_size;     /* size of target char array to
+                                * allocate */
+       isc_result_t result;    /* expected return value */
+       const char *output;     /* expected output string */
+} dns_plugin_expandpath_test_params_t;
 
 /*%
- * Perform a single ns_plugin_expandpath() check using given parameters.
+ * Perform a single dns_plugin_expandpath() check using given parameters.
  */
 static void
-run_full_path_test(const ns_plugin_expandpath_test_params_t *test,
+run_full_path_test(const dns_plugin_expandpath_test_params_t *test,
                   void **state) {
        char **target = (char **)state;
        isc_result_t result;
@@ -86,9 +87,9 @@ run_full_path_test(const ns_plugin_expandpath_test_params_t *test,
        *target = isc_mem_allocate(isc_g_mctx, test->output_size);
 
        /*
-        * Call ns_plugin_expandpath().
+        * Call dns_plugin_expandpath().
         */
-       result = ns_plugin_expandpath(test->input, *target, test->output_size);
+       result = dns_plugin_expandpath(test->input, *target, test->output_size);
 
        /*
         * Check return value.
@@ -114,13 +115,13 @@ run_full_path_test(const ns_plugin_expandpath_test_params_t *test,
        isc_mem_free(isc_g_mctx, *target);
 }
 
-/* test ns_plugin_expandpath() */
-ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
+/* test dns_plugin_expandpath() */
+ISC_RUN_TEST_IMPL(dns_plugin_expandpath) {
        size_t i;
 
-       const ns_plugin_expandpath_test_params_t tests[] = {
+       const dns_plugin_expandpath_test_params_t tests[] = {
                {
-                       NS_TEST_ID("correct use with an absolute path"),
+                       DNS_TEST_ID("correct use with an absolute path"),
                        .input = "/usr/lib/named/foo.so",
                        .exists = true,
                        .output_size = PATH_MAX,
@@ -128,7 +129,7 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = "/usr/lib/named/foo.so",
                },
                {
-                       NS_TEST_ID("correct use with a relative path"),
+                       DNS_TEST_ID("correct use with a relative path"),
                        .input = "../../foo.so",
                        .exists = true,
                        .output_size = PATH_MAX,
@@ -136,7 +137,7 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = "../../foo.so",
                },
                {
-                       NS_TEST_ID("correct use with a filename"),
+                       DNS_TEST_ID("correct use with a filename"),
                        .input = "foo.so",
                        .exists = true,
                        .output_size = PATH_MAX,
@@ -144,8 +145,8 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = NAMED_PLUGINDIR "/foo.so",
                },
                {
-                       NS_TEST_ID("correct use with an absolute path and no "
-                                  "extension"),
+                       DNS_TEST_ID("correct use with an absolute path and no "
+                                   "extension"),
                        .input = "/usr/lib/named/foo",
                        .exists = false,
                        .output_size = PATH_MAX,
@@ -153,8 +154,8 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = "/usr/lib/named/foo" NAMED_PLUGINEXT,
                },
                {
-                       NS_TEST_ID("correct use with a relative path and no "
-                                  "extension"),
+                       DNS_TEST_ID("correct use with a relative path and no "
+                                   "extension"),
                        .input = "../../foo",
                        .exists = false,
                        .output_size = PATH_MAX,
@@ -162,8 +163,8 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = "../../foo" NAMED_PLUGINEXT,
                },
                {
-                       NS_TEST_ID("correct use with a filename and no "
-                                  "extension"),
+                       DNS_TEST_ID("correct use with a filename and no "
+                                   "extension"),
                        .input = "foo",
                        .exists = false,
                        .output_size = PATH_MAX,
@@ -171,8 +172,8 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = NAMED_PLUGINDIR "/foo" NAMED_PLUGINEXT,
                },
                {
-                       NS_TEST_ID("correct use with a filename and no "
-                                  "extension but a name with dots"),
+                       DNS_TEST_ID("correct use with a filename and no "
+                                   "extension but a name with dots"),
                        .input = "foo.bar",
                        .exists = false,
                        .output_size = PATH_MAX,
@@ -180,28 +181,28 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
                        .output = NAMED_PLUGINDIR "/foo.bar" NAMED_PLUGINEXT,
                },
                {
-                       NS_TEST_ID("no space at all in target buffer"),
+                       DNS_TEST_ID("no space at all in target buffer"),
                        .input = "/usr/lib/named/foo.so",
                        .exists = true,
                        .output_size = 0,
                        .result = ISC_R_NOSPACE,
                },
                {
-                       NS_TEST_ID("target buffer too small to fit input"),
+                       DNS_TEST_ID("target buffer too small to fit input"),
                        .input = "/usr/lib/named/foo.so",
                        .exists = true,
                        .output_size = 1,
                        .result = ISC_R_NOSPACE,
                },
                {
-                       NS_TEST_ID("target buffer too small to fit NULL byte"),
+                       DNS_TEST_ID("target buffer too small to fit NULL byte"),
                        .input = "/foo.so",
                        .exists = true,
                        .output_size = 7,
                        .result = ISC_R_NOSPACE,
                },
                {
-                       NS_TEST_ID("target buffer too small to fit full path"),
+                       DNS_TEST_ID("target buffer too small to fit full path"),
                        .input = "foo.so",
                        .exists = true,
                        .output_size = 7,
@@ -215,7 +216,7 @@ ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
 }
 
 ISC_TEST_LIST_START
-ISC_TEST_ENTRY(ns_plugin_expandpath)
+ISC_TEST_ENTRY(dns_plugin_expandpath)
 ISC_TEST_LIST_END
 
 ISC_TEST_MAIN
index 2ce75fcc96b764d4dea85782ed281eb3d02efc29..cc87669148059f6c9feba6ab6e8ae8df4935ce21 100644 (file)
 
 #include <tests/isc.h>
 
+typedef struct dns_test_id {
+       const char *description;
+       int         lineno;
+} dns_test_id_t;
+
+#define DNS_TEST_ID(desc) { .description = desc, .lineno = __LINE__ }
+
 extern dns_zonemgr_t *zonemgr;
 
 typedef struct {
index 8d57c4e36406b3837af5bdf199d690b28a31780d..a0569358b0171ac59755cd9ebce128ae66bbe5bc 100644 (file)
 #include <isc/timer.h>
 #include <isc/util.h>
 
+#include <dns/hooks.h>
 #include <dns/zone.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/interfacemgr.h>
 
 #include <tests/dns.h>
@@ -78,7 +78,7 @@ ns_test_serve_zone(const char *zonename, const char *filename,
  * Set a hooktable on the served zone
  */
 void
-ns_test_serve_zone_sethooktab(ns_hooktable_t *hooktab);
+ns_test_serve_zone_sethooktab(dns_hooktable_t *hooktab);
 
 /*%
  * Release the zone loaded by ns_test_serve_zone().
@@ -127,5 +127,5 @@ ns_test_qctx_destroy(query_ctx_t **qctxp);
 /*%
  * A hook callback interrupting execution at given hook's insertion point.
  */
-ns_hookresult_t
+dns_hookresult_t
 ns_test_hook_catch_call(void *arg, void *data, isc_result_t *resultp);
index 55117d1408d00484a4a658192af61ef1aff81813..e8e432fd47c20dc30fe82dfc6997dac5786af4fd 100644 (file)
 #include <dns/db.h>
 #include <dns/dispatch.h>
 #include <dns/fixedname.h>
+#include <dns/hooks.h>
 #include <dns/name.h>
 #include <dns/view.h>
 #include <dns/zone.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/interfacemgr.h>
 #include <ns/server.h>
 
@@ -140,8 +140,8 @@ teardown_server(void **state) {
 static dns_zone_t *served_zone = NULL;
 
 void
-ns_test_serve_zone_sethooktab(ns_hooktable_t *hooktab) {
-       dns_zone_sethooktable(served_zone, hooktab, ns_hooktable_free);
+ns_test_serve_zone_sethooktab(dns_hooktable_t *hooktab) {
+       dns_zone_sethooktable(served_zone, hooktab, dns_hooktable_free);
 }
 
 isc_result_t
@@ -341,7 +341,7 @@ destroy_message:
  * "data".  Causes execution to be interrupted at hook insertion
  * point.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 extract_qctx(void *arg, void *data, isc_result_t *resultp) {
        query_ctx_t **qctxp;
        query_ctx_t *qctx;
@@ -362,7 +362,7 @@ extract_qctx(void *arg, void *data, isc_result_t *resultp) {
        *qctxp = qctx;
        *resultp = ISC_R_UNSET;
 
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
 /*%
@@ -374,8 +374,8 @@ extract_qctx(void *arg, void *data, isc_result_t *resultp) {
  */
 static isc_result_t
 create_qctx_for_client(ns_client_t *client, query_ctx_t **qctxp) {
-       ns_hooktable_t *saved_hook_table = NULL, *query_hooks = NULL;
-       const ns_hook_t hook = {
+       dns_hooktable_t *saved_hook_table = NULL, *query_hooks = NULL;
+       const dns_hook_t hook = {
                .action = extract_qctx,
                .action_data = qctxp,
        };
@@ -392,16 +392,16 @@ create_qctx_for_client(ns_client_t *client, query_ctx_t **qctxp) {
         * set hooks.
         */
 
-       ns_hooktable_create(isc_g_mctx, &query_hooks);
-       ns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_SETUP, &hook);
+       dns_hooktable_create(isc_g_mctx, &query_hooks);
+       dns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_SETUP, &hook);
 
-       saved_hook_table = ns__hook_table;
-       ns__hook_table = query_hooks;
+       saved_hook_table = dns__hook_table;
+       dns__hook_table = query_hooks;
 
        ns_query_start(client, client->inner.handle);
 
-       ns__hook_table = saved_hook_table;
-       ns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
+       dns__hook_table = saved_hook_table;
+       dns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
 
        isc_nmhandle_detach(&client->inner.reqhandle);
 
@@ -504,14 +504,14 @@ ns_test_qctx_destroy(query_ctx_t **qctxp) {
        isc_mem_put(isc_g_mctx, qctx, sizeof(*qctx));
 }
 
-ns_hookresult_t
+dns_hookresult_t
 ns_test_hook_catch_call(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(data);
 
        *resultp = ISC_R_UNSET;
 
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
 isc_result_t
index 7d4e2e30fafb8b3653f737884c3c6d7a72e7886d..55eaeb96acba264cb7c90b1f9e5a63e1b092bdff 100644 (file)
@@ -11,7 +11,6 @@
 
 foreach unit : [
     'notify',
-    'plugin',
     'query',
 ]
     test_bin = executable(
index 53a4964147c8593cf011e06893aff080e2d9c84e..15381fe75528c7d3bb59d0fcb82a5c5c44734f46 100644 (file)
 #include <isc/util.h>
 
 #include <dns/badcache.h>
+#include <dns/hooks.h>
 #include <dns/lib.h>
 #include <dns/view.h>
 #include <dns/zone.h>
 
 #include <ns/client.h>
-#include <ns/hooks.h>
 #include <ns/query.h>
 #include <ns/server.h>
 #include <ns/stats.h>
@@ -76,10 +76,10 @@ typedef struct {
  */
 static void
 run_sfcache_test(const ns__query_sfcache_test_params_t *test) {
-       ns_hooktable_t *query_hooks = NULL;
+       dns_hooktable_t *query_hooks = NULL;
        query_ctx_t *qctx = NULL;
        isc_result_t result;
-       const ns_hook_t hook = {
+       const dns_hook_t hook = {
                .action = ns_test_hook_catch_call,
        };
 
@@ -91,9 +91,9 @@ run_sfcache_test(const ns__query_sfcache_test_params_t *test) {
         * Interrupt execution if ns_query_done() is called.
         */
 
-       ns_hooktable_create(isc_g_mctx, &query_hooks);
-       ns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_DONE_BEGIN, &hook);
-       ns__hook_table = query_hooks;
+       dns_hooktable_create(isc_g_mctx, &query_hooks);
+       dns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_DONE_BEGIN, &hook);
+       dns__hook_table = query_hooks;
 
        /*
         * Construct a query context for a ./NS query with given flags.
@@ -153,7 +153,7 @@ run_sfcache_test(const ns__query_sfcache_test_params_t *test) {
         * Clean up.
         */
        ns_test_qctx_destroy(&qctx);
-       ns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
+       dns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
 }
 
 /* test ns__query_sfcache() */
@@ -277,10 +277,10 @@ typedef struct {
  */
 static void
 run_start_test(const ns__query_start_test_params_t *test) {
-       ns_hooktable_t *query_hooks = NULL;
+       dns_hooktable_t *query_hooks = NULL;
        query_ctx_t *qctx = NULL;
        isc_result_t result;
-       const ns_hook_t hook = {
+       const dns_hook_t hook = {
                .action = ns_test_hook_catch_call,
        };
 
@@ -294,10 +294,10 @@ run_start_test(const ns__query_start_test_params_t *test) {
        /*
         * Interrupt execution if query_lookup() or ns_query_done() is called.
         */
-       ns_hooktable_create(isc_g_mctx, &query_hooks);
-       ns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_LOOKUP_BEGIN, &hook);
-       ns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_DONE_BEGIN, &hook);
-       ns__hook_table = query_hooks;
+       dns_hooktable_create(isc_g_mctx, &query_hooks);
+       dns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_LOOKUP_BEGIN, &hook);
+       dns_hook_add(query_hooks, isc_g_mctx, NS_QUERY_DONE_BEGIN, &hook);
+       dns__hook_table = query_hooks;
 
        /*
         * Construct a query context using the supplied parameters.
@@ -412,7 +412,7 @@ run_start_test(const ns__query_start_test_params_t *test) {
                ns_test_cleanup_zone();
        }
        ns_test_qctx_destroy(&qctx);
-       ns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
+       dns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
 }
 
 /* test ns__query_start() */
@@ -593,26 +593,26 @@ ISC_LOOP_TEST_IMPL(ns__query_start) {
  * Structure containing parameters for ns__query_hookasync_test().
  */
 typedef struct {
-       const ns_test_id_t id;     /* libns test identifier */
-       ns_hookpoint_t hookpoint;  /* hook point specified for resume */
-       ns_hookpoint_t hookpoint2; /* expected hook point used after resume */
-       ns_hook_action_t action;   /* action for the hook point */
-       isc_result_t start_result; /* result of 'runasync' */
-       bool quota_ok;             /* true if recursion quota should be okay */
-       bool do_cancel;            /* true if query should be canceled
-                                   * in test */
+       const ns_test_id_t id;      /* libns test identifier */
+       dns_hookpoint_t hookpoint;  /* hook point specified for resume */
+       dns_hookpoint_t hookpoint2; /* expected hook point used after resume */
+       dns_hook_action_t action;   /* action for the hook point */
+       isc_result_t start_result;  /* result of 'runasync' */
+       bool quota_ok;              /* true if recursion quota should be okay */
+       bool do_cancel;             /* true if query should be canceled
+                                    * in test */
 } ns__query_hookasync_test_params_t;
 
 /* Data structure passed from tests to hooks */
 typedef struct hookasync_data {
-       bool async;                   /* true if in a hook-triggered
-                                      * asynchronous process */
-       bool canceled;                /* true if the query has been canceled  */
-       isc_result_t start_result;    /* result of 'runasync' */
-       ns_hook_resume_t *rev;        /* resume state sent on completion */
-       query_ctx_t qctx;             /* shallow copy of qctx passed to hook */
-       ns_hookpoint_t hookpoint;     /* specifies where to resume */
-       ns_hookpoint_t lasthookpoint; /* remember the last hook point called */
+       bool async;                /* true if in a hook-triggered
+                                   * asynchronous process */
+       bool canceled;             /* true if the query has been canceled  */
+       isc_result_t start_result; /* result of 'runasync' */
+       dns_hook_resume_t *rev;    /* resume state sent on completion */
+       query_ctx_t qctx;          /* shallow copy of qctx passed to hook */
+       dns_hookpoint_t hookpoint; /* specifies where to resume */
+       dns_hookpoint_t lasthookpoint; /* remember the last hook point called */
 } hookasync_data_t;
 
 /*
@@ -621,8 +621,8 @@ typedef struct hookasync_data {
  * this is actually called; otherwise tests would fail due to memory leak.
  */
 static void
-destroy_hookasyncctx(ns_hookasync_t **ctxp) {
-       ns_hookasync_t *ctx = *ctxp;
+destroy_hookasyncctx(dns_hookasync_t **ctxp) {
+       dns_hookasync_t *ctx = *ctxp;
 
        *ctxp = NULL;
        isc_mem_putanddetach(&ctx->mctx, ctx, sizeof(*ctx));
@@ -630,7 +630,7 @@ destroy_hookasyncctx(ns_hookasync_t **ctxp) {
 
 /* 'cancel' callback of hook recursion ctx. */
 static void
-cancel_hookasyncctx(ns_hookasync_t *ctx) {
+cancel_hookasyncctx(dns_hookasync_t *ctx) {
        /* Mark the hook data so the test can confirm this is called. */
        ((hookasync_data_t *)ctx->private)->canceled = true;
 }
@@ -638,10 +638,10 @@ cancel_hookasyncctx(ns_hookasync_t *ctx) {
 /* 'runasync' callback passed to ns_query_hookasync */
 static isc_result_t
 test_hookasync(query_ctx_t *qctx, isc_mem_t *mctx, void *arg, isc_loop_t *loop,
-              isc_job_cb cb, void *evarg, ns_hookasync_t **ctxp) {
+              isc_job_cb cb, void *evarg, dns_hookasync_t **ctxp) {
        hookasync_data_t *asdata = arg;
-       ns_hookasync_t *ctx = NULL;
-       ns_hook_resume_t *rev = NULL;
+       dns_hookasync_t *ctx = NULL;
+       dns_hook_resume_t *rev = NULL;
 
        if (asdata->start_result != ISC_R_SUCCESS) {
                return asdata->start_result;
@@ -649,10 +649,10 @@ test_hookasync(query_ctx_t *qctx, isc_mem_t *mctx, void *arg, isc_loop_t *loop,
 
        ctx = isc_mem_get(mctx, sizeof(*ctx));
        rev = isc_mem_get(mctx, sizeof(*rev));
-       *rev = (ns_hook_resume_t){
+       *rev = (dns_hook_resume_t){
                .hookpoint = asdata->hookpoint,
                .origresult = DNS_R_NXDOMAIN,
-               .saved_qctx = qctx,
+               .context = qctx,
                .ctx = ctx,
                .loop = loop,
                .cb = cb,
@@ -661,7 +661,7 @@ test_hookasync(query_ctx_t *qctx, isc_mem_t *mctx, void *arg, isc_loop_t *loop,
 
        asdata->rev = rev;
 
-       *ctx = (ns_hookasync_t){
+       *ctx = (dns_hookasync_t){
                .destroy = destroy_hookasyncctx,
                .cancel = cancel_hookasyncctx,
                .private = asdata,
@@ -678,9 +678,9 @@ test_hookasync(query_ctx_t *qctx, isc_mem_t *mctx, void *arg, isc_loop_t *loop,
  * remembered in the hook data, so that the test can confirm which hook point
  * was last used.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_common(void *arg, void *data, isc_result_t *resultp,
-                 ns_hookpoint_t hookpoint) {
+                 dns_hookpoint_t hookpoint) {
        query_ctx_t *qctx = arg;
        hookasync_data_t *asdata = data;
        isc_result_t result;
@@ -714,116 +714,116 @@ hook_async_common(void *arg, void *data, isc_result_t *resultp,
        }
 
        *resultp = ISC_R_UNSET;
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_setup(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_SETUP);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_start_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_START_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_lookup_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_LOOKUP_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_resume_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_RESUME_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_got_answer_begin(void *arg, void *data,
                                  isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_GOT_ANSWER_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_respond_any_begin(void *arg, void *data,
                                   isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp,
                                 NS_QUERY_RESPOND_ANY_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_addanswer_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_ADDANSWER_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_notfound_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_NOTFOUND_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_prep_delegation_begin(void *arg, void *data,
                                       isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp,
                                 NS_QUERY_PREP_DELEGATION_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_zone_delegation_begin(void *arg, void *data,
                                       isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp,
                                 NS_QUERY_ZONE_DELEGATION_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_delegation_begin(void *arg, void *data,
                                  isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_DELEGATION_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_delegation_recurse_begin(void *arg, void *data,
                                          isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp,
                                 NS_QUERY_DELEGATION_RECURSE_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_nodata_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_NODATA_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_nxdomain_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_NXDOMAIN_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_ncache_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_NCACHE_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_cname_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_CNAME_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_dname_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_DNAME_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_respond_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_RESPOND_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_response_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp,
                                 NS_QUERY_PREP_RESPONSE_BEGIN);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_query_done_begin(void *arg, void *data, isc_result_t *resultp) {
        return hook_async_common(arg, data, resultp, NS_QUERY_DONE_BEGIN);
 }
@@ -838,7 +838,7 @@ run_hookasync_test(const ns__query_hookasync_test_params_t *test) {
                .start_result = test->start_result,
                .hookpoint = test->hookpoint,
        };
-       const ns_hook_t testhook = {
+       const dns_hook_t testhook = {
                .action = test->action,
                .action_data = &asdata,
        };
@@ -850,17 +850,17 @@ run_hookasync_test(const ns__query_hookasync_test_params_t *test) {
         * Its action will specify various different resume points (unusual
         * in practice, but that's fine for the testing purpose).
         */
-       ns__hook_table = NULL;
-       ns_hooktable_create(isc_g_mctx, &ns__hook_table);
-       ns_hook_add(ns__hook_table, isc_g_mctx, NS_QUERY_START_BEGIN,
-                   &testhook);
+       dns__hook_table = NULL;
+       dns_hooktable_create(isc_g_mctx, &dns__hook_table);
+       dns_hook_add(dns__hook_table, isc_g_mctx, NS_QUERY_START_BEGIN,
+                    &testhook);
        if (test->hookpoint2 != NS_QUERY_START_BEGIN) {
                /*
                 * unless testing START_BEGIN itself, specify the hook for the
                 * expected resume point, too.
                 */
-               ns_hook_add(ns__hook_table, isc_g_mctx, test->hookpoint2,
-                           &testhook);
+               dns_hook_add(dns__hook_table, isc_g_mctx, test->hookpoint2,
+                            &testhook);
        }
 
        {
@@ -964,7 +964,7 @@ run_hookasync_test(const ns__query_hookasync_test_params_t *test) {
         * qctx->client may have been invalidated while we still need it.
         */
        ns_test_qctx_destroy(&qctx);
-       ns_hooktable_free(isc_g_mctx, (void **)&ns__hook_table);
+       dns_hooktable_free(isc_g_mctx, (void **)&dns__hook_table);
        if (!test->quota_ok) {
                isc_quota_release(&sctx->recursionquota);
        }
@@ -1226,7 +1226,7 @@ ISC_LOOP_TEST_IMPL(ns__query_hookasync) {
 typedef struct {
        const ns_test_id_t id;     /* libns test identifier */
        const char *qname;         /* QNAME */
-       ns_hookpoint_t hookpoint;  /* hook point specified for resume */
+       dns_hookpoint_t hookpoint; /* hook point specified for resume */
        isc_result_t start_result; /* result of 'runasync' */
        bool do_cancel;            /* true if query should be canceled
                                    * in test */
@@ -1237,8 +1237,8 @@ typedef struct {
 typedef struct hookasync_e2e_data {
        bool async;                /* true if in a hook-triggered
                                    * asynchronous process */
-       ns_hook_resume_t *rev;     /* resume state sent on completion */
-       ns_hookpoint_t hookpoint;  /* specifies where to resume */
+       dns_hook_resume_t *rev;    /* resume state sent on completion */
+       dns_hookpoint_t hookpoint; /* specifies where to resume */
        isc_result_t start_result; /* result of 'runasync' */
        dns_rcode_t expected_rcode;
        bool done; /* if SEND_DONE hook is called */
@@ -1246,7 +1246,7 @@ typedef struct hookasync_e2e_data {
 
 /* Cancel callback.  Just need to be defined, it doesn't have to do anything. */
 static void
-cancel_e2ehookasyncctx(ns_hookasync_t *ctx) {
+cancel_e2ehookasyncctx(dns_hookasync_t *ctx) {
        UNUSED(ctx);
 }
 
@@ -1254,9 +1254,9 @@ cancel_e2ehookasyncctx(ns_hookasync_t *ctx) {
 static isc_result_t
 test_hookasync_e2e(query_ctx_t *qctx, isc_mem_t *mctx, void *arg,
                   isc_loop_t *loop, isc_job_cb cb, void *evarg,
-                  ns_hookasync_t **ctxp) {
-       ns_hookasync_t *ctx = NULL;
-       ns_hook_resume_t *rev = NULL;
+                  dns_hookasync_t **ctxp) {
+       dns_hookasync_t *ctx = NULL;
+       dns_hook_resume_t *rev = NULL;
        hookasync_e2e_data_t *asdata = arg;
 
        if (asdata->start_result != ISC_R_SUCCESS) {
@@ -1265,9 +1265,9 @@ test_hookasync_e2e(query_ctx_t *qctx, isc_mem_t *mctx, void *arg,
 
        ctx = isc_mem_get(mctx, sizeof(*ctx));
        rev = isc_mem_get(mctx, sizeof(*rev));
-       *rev = (ns_hook_resume_t){
+       *rev = (dns_hook_resume_t){
                .hookpoint = asdata->hookpoint,
-               .saved_qctx = qctx,
+               .context = qctx,
                .ctx = ctx,
                .loop = loop,
                .cb = cb,
@@ -1276,7 +1276,7 @@ test_hookasync_e2e(query_ctx_t *qctx, isc_mem_t *mctx, void *arg,
 
        asdata->rev = rev;
 
-       *ctx = (ns_hookasync_t){
+       *ctx = (dns_hookasync_t){
                .destroy = destroy_hookasyncctx,
                .cancel = cancel_e2ehookasyncctx,
                .private = asdata,
@@ -1287,7 +1287,7 @@ test_hookasync_e2e(query_ctx_t *qctx, isc_mem_t *mctx, void *arg,
        return ISC_R_SUCCESS;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 hook_async_e2e(void *arg, void *data, isc_result_t *resultp) {
        query_ctx_t *qctx = arg;
        hookasync_e2e_data_t *asdata = data;
@@ -1298,18 +1298,18 @@ hook_async_e2e(void *arg, void *data, isc_result_t *resultp) {
                result = ns_query_hookasync(qctx, test_hookasync_e2e, asdata);
                if (result != ISC_R_SUCCESS) {
                        *resultp = result;
-                       return NS_HOOK_RETURN;
+                       return DNS_HOOK_RETURN;
                }
 
                asdata->async = true;
                asdata->rev->origresult = *resultp; /* save it for resume */
                *resultp = ISC_R_UNSET;
-               return NS_HOOK_RETURN;
+               return DNS_HOOK_RETURN;
        } else {
                /* Resume from the completion of async event */
                asdata->async = false;
                /* Don't touch 'resultp' */
-               return NS_HOOK_CONTINUE;
+               return DNS_HOOK_CONTINUE;
        }
 }
 
@@ -1317,7 +1317,7 @@ hook_async_e2e(void *arg, void *data, isc_result_t *resultp) {
  * Check whether the final response has expected the RCODE according to
  * the test scenario.
  */
-static ns_hookresult_t
+static dns_hookresult_t
 hook_donesend(void *arg, void *data, isc_result_t *resultp) {
        query_ctx_t *qctx = arg;
        hookasync_e2e_data_t *asdata = data;
@@ -1325,7 +1325,7 @@ hook_donesend(void *arg, void *data, isc_result_t *resultp) {
        INSIST(qctx->client->message->rcode == asdata->expected_rcode);
        asdata->done = true; /* Let the test know this hook is called */
        *resultp = ISC_R_UNSET;
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
 static void
@@ -1339,11 +1339,11 @@ run_hookasync_e2e_test(const ns__query_hookasync_e2e_test_params_t *test) {
                .expected_rcode = test->expected_rcode,
                .done = false,
        };
-       const ns_hook_t donesend_hook = {
+       const dns_hook_t donesend_hook = {
                .action = hook_donesend,
                .action_data = &asdata,
        };
-       const ns_hook_t hook = {
+       const dns_hook_t hook = {
                .action = hook_async_e2e,
                .action_data = &asdata,
        };
@@ -1353,11 +1353,11 @@ run_hookasync_e2e_test(const ns__query_hookasync_e2e_test_params_t *test) {
                .with_cache = true,
        };
 
-       ns__hook_table = NULL;
-       ns_hooktable_create(isc_g_mctx, &ns__hook_table);
-       ns_hook_add(ns__hook_table, isc_g_mctx, test->hookpoint, &hook);
-       ns_hook_add(ns__hook_table, isc_g_mctx, NS_QUERY_DONE_SEND,
-                   &donesend_hook);
+       dns__hook_table = NULL;
+       dns_hooktable_create(isc_g_mctx, &dns__hook_table);
+       dns_hook_add(dns__hook_table, isc_g_mctx, test->hookpoint, &hook);
+       dns_hook_add(dns__hook_table, isc_g_mctx, NS_QUERY_DONE_SEND,
+                    &donesend_hook);
 
        result = ns_test_qctx_create(&qctx_params, &qctx);
        INSIST(result == ISC_R_SUCCESS);
@@ -1406,7 +1406,7 @@ run_hookasync_e2e_test(const ns__query_hookasync_e2e_test_params_t *test) {
        /* Cleanup */
        ns_test_qctx_destroy(&qctx);
        ns_test_cleanup_zone();
-       ns_hooktable_free(isc_g_mctx, (void **)&ns__hook_table);
+       dns_hooktable_free(isc_g_mctx, (void **)&dns__hook_table);
 }
 
 ISC_LOOP_TEST_IMPL(ns__query_hookasync_e2e) {
@@ -1456,12 +1456,12 @@ ISC_LOOP_TEST_IMPL(ns__query_hookasync_e2e) {
 /*
  * Tests covering the correctness of hook call order, i.e. hooks from a zone are
  * called first, then hooks from a view, then the default hook table. And any
- * hook returning NS_HOOK_RETURN interrupt the whole chain
+ * hook returning DNS_HOOK_RETURN interrupt the whole chain
  */
 typedef struct {
-       ns_hook_action_t zonehookactions[2];
-       ns_hook_action_t viewhookactions[2];
-       ns_hook_action_t defaulthookactions[2];
+       dns_hook_action_t zonehookactions[2];
+       dns_hook_action_t viewhookactions[2];
+       dns_hook_action_t defaulthookactions[2];
        const char *expected;
 } ns__query_hook_test_params_t;
 
@@ -1473,75 +1473,75 @@ ns__query_test_concat(char *base, const char *tail) {
        snprintf(base, sizeof(b), "%s%s", b, tail);
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 ns__query_test_zonehook1(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(resultp);
 
        ns__query_test_concat(data, "z1");
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 ns__query_test_zonehook2(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(resultp);
 
        ns__query_test_concat(data, "z2");
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 ns__query_test_viewhook1(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(resultp);
 
        ns__query_test_concat(data, "v1");
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 ns__query_test_viewhook2(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(resultp);
 
        ns__query_test_concat(data, "v2");
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 ns__query_test_defaulthook1(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(resultp);
 
        ns__query_test_concat(data, "d1");
-       return NS_HOOK_CONTINUE;
+       return DNS_HOOK_CONTINUE;
 }
 
-static ns_hookresult_t
+static dns_hookresult_t
 ns__query_test_defaulthook2(void *arg, void *data, isc_result_t *resultp) {
        UNUSED(arg);
        UNUSED(resultp);
 
        ns__query_test_concat(data, "d2");
-       return NS_HOOK_RETURN;
+       return DNS_HOOK_RETURN;
 }
 
 static bool
-ns__query_test_setup_hooks(const ns_hook_t *h1, const ns_hook_t *h2,
-                          ns_hooktable_t **tp) {
+ns__query_test_setup_hooks(const dns_hook_t *h1, const dns_hook_t *h2,
+                          dns_hooktable_t **tp) {
        if (h1->action || h2->action) {
                INSIST(*tp == NULL);
-               ns_hooktable_create(isc_g_mctx, tp);
+               dns_hooktable_create(isc_g_mctx, tp);
 
                if (h1->action) {
-                       ns_hook_add(*tp, isc_g_mctx, NS_QUERY_NXDOMAIN_BEGIN,
-                                   h1);
+                       dns_hook_add(*tp, isc_g_mctx, NS_QUERY_NXDOMAIN_BEGIN,
+                                    h1);
                }
 
                if (h2->action) {
-                       ns_hook_add(*tp, isc_g_mctx, NS_QUERY_NXDOMAIN_BEGIN,
-                                   h2);
+                       dns_hook_add(*tp, isc_g_mctx, NS_QUERY_NXDOMAIN_BEGIN,
+                                    h2);
                }
 
                return true;
@@ -1555,8 +1555,8 @@ ns__query_test_run_hookchain_test(const ns__query_hook_test_params_t *test) {
        isc_result_t result;
        query_ctx_t *qctx = NULL;
        char buffer[512] = { 0 };
-       ns_hooktable_t *zone_hooktab = NULL;
-       ns_hooktable_t *view_hooktab = NULL;
+       dns_hooktable_t *zone_hooktab = NULL;
+       dns_hooktable_t *view_hooktab = NULL;
 
        const ns_test_qctx_create_params_t qctx_params = {
                .qname = "idontexists.foo",
@@ -1564,23 +1564,23 @@ ns__query_test_run_hookchain_test(const ns__query_hook_test_params_t *test) {
                .with_cache = true,
        };
 
-       const ns_hook_t zonehook1 = { .action = test->zonehookactions[0],
-                                     .action_data = buffer };
+       const dns_hook_t zonehook1 = { .action = test->zonehookactions[0],
+                                      .action_data = buffer };
 
-       const ns_hook_t zonehook2 = { .action = test->zonehookactions[1],
-                                     .action_data = buffer };
+       const dns_hook_t zonehook2 = { .action = test->zonehookactions[1],
+                                      .action_data = buffer };
 
-       const ns_hook_t viewhook1 = { .action = test->viewhookactions[0],
-                                     .action_data = buffer };
+       const dns_hook_t viewhook1 = { .action = test->viewhookactions[0],
+                                      .action_data = buffer };
 
-       const ns_hook_t viewhook2 = { .action = test->viewhookactions[1],
-                                     .action_data = buffer };
+       const dns_hook_t viewhook2 = { .action = test->viewhookactions[1],
+                                      .action_data = buffer };
 
-       const ns_hook_t defaulthook1 = { .action = test->defaulthookactions[0],
-                                        .action_data = buffer };
+       const dns_hook_t defaulthook1 = { .action = test->defaulthookactions[0],
+                                         .action_data = buffer };
 
-       const ns_hook_t defaulthook2 = { .action = test->defaulthookactions[1],
-                                        .action_data = buffer };
+       const dns_hook_t defaulthook2 = { .action = test->defaulthookactions[1],
+                                         .action_data = buffer };
 
        /*
         * Create a fake query context
@@ -1613,7 +1613,7 @@ ns__query_test_run_hookchain_test(const ns__query_hook_test_params_t *test) {
         * Setup the default hook table
         */
        (void)ns__query_test_setup_hooks(&defaulthook1, &defaulthook2,
-                                        &ns__hook_table);
+                                        &dns__hook_table);
 
        /*
         * Handling the response
@@ -1639,12 +1639,12 @@ ns__query_test_run_hookchain_test(const ns__query_hook_test_params_t *test) {
        ns_test_qctx_destroy(&qctx);
        ns_test_cleanup_zone();
 
-       if (ns__hook_table) {
-               ns_hooktable_free(isc_g_mctx, (void **)&ns__hook_table);
+       if (dns__hook_table) {
+               dns_hooktable_free(isc_g_mctx, (void **)&dns__hook_table);
        }
 
        if (view_hooktab) {
-               ns_hooktable_free(isc_g_mctx, (void **)&view_hooktab);
+               dns_hooktable_free(isc_g_mctx, (void **)&view_hooktab);
        }
 }