static isc_result_t
parse_parameters(filter_instance_t *inst, const char *parameters,
- const char *cfg_file, unsigned long cfg_line,
- const void *cfg, void *actx, ns_hookctx_t *hctx)
+ const void *cfg, const char *cfg_file, unsigned long cfg_line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx)
{
isc_result_t result = ISC_R_SUCCESS;
cfg_parser_t *parser = NULL;
const cfg_obj_t *obj = NULL;
isc_buffer_t b;
- CHECK(cfg_parser_create(hctx->mctx, hctx->lctx, &parser));
+ CHECK(cfg_parser_create(mctx, lctx, &parser));
isc_buffer_constinit(&b, parameters, strlen(parameters));
isc_buffer_add(&b, strlen(parameters));
CHECK(cfg_parse_buffer4(parser, &b, cfg_file, cfg_line,
&cfg_type_parameters, 0, ¶m_obj));
- CHECK(check_syntax(param_obj, cfg, hctx->mctx, hctx->lctx, actx));
+ CHECK(check_syntax(param_obj, cfg, mctx, lctx, actx));
CHECK(parse_filter_aaaa_on(param_obj, "filter-aaaa-on-v4",
&inst->v4_aaaa));
result = cfg_map_get(param_obj, "filter-aaaa", &obj);
if (result == ISC_R_SUCCESS) {
CHECK(cfg_acl_fromconfig(obj, (const cfg_obj_t *) cfg,
- hctx->lctx, (cfg_aclconfctx_t *) actx,
- hctx->mctx, 0, &inst->aaaa_acl));
+ lctx, (cfg_aclconfctx_t *) actx,
+ mctx, 0, &inst->aaaa_acl));
} else {
- CHECK(dns_acl_any(hctx->mctx, &inst->aaaa_acl));
+ CHECK(dns_acl_any(mctx, &inst->aaaa_acl));
}
cleanup:
*/
isc_result_t
hook_register(const char *parameters,
- const char *cfg_file, unsigned long cfg_line,
- const void *cfg, void *actx, ns_hookctx_t *hctx,
+ const void *cfg, const char *cfg_file, unsigned long cfg_line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx,
ns_hooktable_t *hooktable, void **instp)
{
filter_instance_t *inst = NULL;
isc_result_t result;
- isc_log_write(hctx->lctx, NS_LOGCATEGORY_GENERAL,
+ isc_log_write(lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_HOOKS, ISC_LOG_INFO,
"registering 'filter-aaaa' "
"module from %s:%lu, %s parameters",
cfg_file, cfg_line, parameters != NULL ? "with" : "no");
- inst = isc_mem_get(hctx->mctx, sizeof(*inst));
+ inst = isc_mem_get(mctx, sizeof(*inst));
memset(inst, 0, sizeof(*inst));
- isc_mem_attach(hctx->mctx, &inst->mctx);
+ isc_mem_attach(mctx, &inst->mctx);
if (parameters != NULL) {
- CHECK(parse_parameters(inst, parameters,
- cfg_file, cfg_line,
- cfg, actx, hctx));
+ CHECK(parse_parameters(inst, parameters, cfg, cfg_file,
+ cfg_line, mctx, lctx, actx));
}
- CHECK(isc_mempool_create(hctx->mctx, sizeof(filter_data_t),
+ CHECK(isc_mempool_create(mctx, sizeof(filter_data_t),
&inst->datapool));
- CHECK(isc_ht_init(&inst->ht, hctx->mctx, 16));
+ CHECK(isc_ht_init(&inst->ht, mctx, 16));
/*
* Fill the mempool with 1K filter_aaaa state objects at
/*
* Set hook points in the view's hooktable.
*/
- install_hooks(hooktable, hctx->mctx, inst);
+ install_hooks(hooktable, mctx, inst);
*instp = inst;
}
isc_result_t
-hook_check(const char *parameters, const char *cfg_file, unsigned long cfg_line,
- const void *cfg, isc_mem_t *mctx, isc_log_t *lctx, void *actx)
+hook_check(const char *parameters,
+ const void *cfg, const char *cfg_file, unsigned long cfg_line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx)
{
isc_result_t result = ISC_R_SUCCESS;
cfg_parser_t *parser = NULL;
static isc_result_t
configure_hook(dns_view_t *view, const cfg_obj_t *hook,
- const cfg_obj_t *config, ns_hookctx_t *hctx)
+ const cfg_obj_t *config)
{
isc_result_t result = ISC_R_SUCCESS;
const cfg_obj_t *obj;
parameters = cfg_obj_asstring(obj);
}
result = ns_module_load(library, parameters,
- cfg_obj_file(obj), cfg_obj_line(obj),
- config, named_g_aclconfctx,
- hctx, view->modlist, view->hooktable);
+ config, cfg_obj_file(obj), cfg_obj_line(obj),
+ named_g_mctx, named_g_lctx, named_g_aclconfctx,
+ view);
if (result != ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
bool old_rpz_ok = false;
isc_dscp_t dscp4 = -1, dscp6 = -1;
dns_dyndbctx_t *dctx = NULL;
- ns_hookctx_t *hctx = NULL;
unsigned int resolver_param;
dns_ntatable_t *ntatable = NULL;
const char *qminmode = NULL;
#ifdef HAVE_DLOPEN
if (hook_list != NULL) {
- CHECK(ns_hook_createctx(mctx, view, &hctx));
-
INSIST(view->hooktable == NULL);
CHECK(ns_hooktable_create(view->mctx,
(ns_hooktable_t **) &view->hooktable));
{
const cfg_obj_t *hook = cfg_listelt_value(element);
- CHECK(configure_hook(view, hook, config, hctx));
+ CHECK(configure_hook(view, hook, config));
}
#endif
if (dctx != NULL) {
dns_dyndb_destroyctx(&dctx);
}
- if (hctx != NULL) {
- ns_hook_destroyctx(&hctx);
- }
return (result);
}
if (obj != NULL && cfg_obj_isstring(obj)) {
parameters = cfg_obj_asstring(obj);
}
- tresult = ns_module_check(library, parameters,
+ tresult = ns_module_check(library, parameters, config,
cfg_obj_file(obj), cfg_obj_line(obj),
- config, mctx, logctx, actx);
+ mctx, logctx, actx);
if (tresult != ISC_R_SUCCESS) {
cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
"%s: module check failed: %s",
#endif /* HAVE_DLFCN_H */
isc_result_t
-ns_module_load(const char *modpath, const char *parameters,
- const char *cfg_file, unsigned long cfg_line,
- const void *cfg, void *actx, ns_hookctx_t *hctx,
- ns_modlist_t *modlist, ns_hooktable_t *hooktable)
+ns_module_load(const char *modpath, const char *parameters, const void *cfg,
+ const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
+ isc_log_t *lctx, void *actx, dns_view_t *view)
{
isc_result_t result;
ns_module_t *hmod = NULL;
- REQUIRE(NS_HOOKCTX_VALID(hctx));
- REQUIRE(modlist != NULL);
- REQUIRE(hooktable != NULL);
+ REQUIRE(mctx != NULL);
+ REQUIRE(lctx != NULL);
+ REQUIRE(view != NULL);
isc_log_write(ns_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_HOOKS, ISC_LOG_INFO,
"loading module '%s'", modpath);
- CHECK(load_library(hctx->mctx, modpath, &hmod));
+ CHECK(load_library(mctx, modpath, &hmod));
isc_log_write(ns_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_HOOKS, ISC_LOG_INFO,
"registering module '%s'", modpath);
- CHECK(hmod->register_func(parameters, cfg_file, cfg_line,
- cfg, actx, hctx, hooktable, &hmod->inst));
+ CHECK(hmod->register_func(parameters, cfg, cfg_file, cfg_line,
+ mctx, lctx, actx, view->hooktable,
+ &hmod->inst));
- ISC_LIST_APPEND(*modlist, hmod, link);
+ ISC_LIST_APPEND(*(ns_modlist_t *)view->modlist, hmod, link);
cleanup:
if (result != ISC_R_SUCCESS && hmod != NULL) {
isc_result_t
ns_module_check(const char *modpath, const char *parameters,
- const char *cfg_file, unsigned long cfg_line,
- const void *cfg, isc_mem_t *mctx, isc_log_t *lctx, void *actx)
+ const void *cfg, const char *cfg_file, unsigned long cfg_line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx)
{
isc_result_t result;
ns_module_t *hmod = NULL;
CHECK(load_library(mctx, modpath, &hmod));
- result = hmod->check_func(parameters, cfg_file, cfg_line,
- cfg, mctx, lctx, actx);
+ result = hmod->check_func(parameters, cfg, cfg_file, cfg_line,
+ mctx, lctx, actx);
cleanup:
if (hmod != NULL) {
return (result);
}
-isc_result_t
-ns_hook_createctx(isc_mem_t *mctx, dns_view_t *view, ns_hookctx_t **hctxp) {
- ns_hookctx_t *hctx = NULL;
-
- REQUIRE(hctxp != NULL && *hctxp == NULL);
-
- hctx = isc_mem_get(mctx, sizeof(*hctx));
- memset(hctx, 0, sizeof(*hctx));
- hctx->lctx = ns_lctx;
-
- dns_view_attach(view, &hctx->view);
-
- isc_mem_attach(mctx, &hctx->mctx);
- hctx->magic = NS_HOOKCTX_MAGIC;
-
- *hctxp = hctx;
-
- return (ISC_R_SUCCESS);
-}
-
-void
-ns_hook_destroyctx(ns_hookctx_t **hctxp) {
- ns_hookctx_t *hctx = NULL;
-
- REQUIRE(hctxp != NULL && NS_HOOKCTX_VALID(*hctxp));
-
- hctx = *hctxp;
- *hctxp = NULL;
-
- hctx->magic = 0;
-
- dns_view_detach(&hctx->view);
- isc_mem_putanddetach(&hctx->mctx, hctx, sizeof(*hctx));
-}
-
void
ns_hooktable_init(ns_hooktable_t *hooktable) {
int i;
*/
LIBNS_EXTERNAL_DATA extern ns_hooktable_t *ns__hook_table;
-/*!
- * Context for initializing a hook module.
- *
- * This structure passes data to which a hook module will need
- * access -- server memory context, hash initializer, log context, etc.
- * The structure doesn't persist beyond configuring the hook module.
- * The module's register function should attach to all reference-counted
- * variables and its destroy function should detach from them.
- */
-typedef struct ns_hookctx {
- unsigned int magic;
- dns_view_t *view;
- isc_mem_t *mctx;
- isc_log_t *lctx;
-} ns_hookctx_t;
-
-#define NS_HOOKCTX_MAGIC ISC_MAGIC('H', 'k', 'c', 'x')
-#define NS_HOOKCTX_VALID(h) ISC_MAGIC_VALID(h, NS_HOOKCTX_MAGIC)
-
/*
* API version
*
typedef isc_result_t
ns_hook_register_t(const char *parameters,
- const char *file, unsigned long line,
- const void *cfg, void *actx, ns_hookctx_t *hctx,
+ const void *cfg, const char *file, unsigned long line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx,
ns_hooktable_t *hooktable, void **instp);
/*%<
* Called when registering a new module.
*/
typedef isc_result_t
-ns_hook_check_t(const char *parameters, const char *file, unsigned long line,
- const void *cfg, isc_mem_t *mctx, isc_log_t *lctx, void *actx);
+ns_hook_check_t(const char *parameters,
+ const void *cfg, const char *file, unsigned long line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx);
/*%<
* Check the validity of 'parameters'.
*/
ns_hook_register_t hook_register;
ns_hook_version_t hook_version;
-isc_result_t
-ns_hook_createctx(isc_mem_t *mctx, dns_view_t *view, ns_hookctx_t **hctxp);
-void
-ns_hook_destroyctx(ns_hookctx_t **hctxp);
-/*%<
- * Create/destroy a hook module context.
- */
-
isc_result_t
ns_module_load(const char *modpath, const char *parameters,
- const char *cfg_file, unsigned long cfg_line,
- const void *cfg, void *actx, ns_hookctx_t *hctx,
- ns_modlist_t *modlist, ns_hooktable_t *hooktable);
+ const void *cfg, const char *cfg_file, unsigned long cfg_line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx,
+ dns_view_t *view);
/*%<
* Load the module specified from the file 'modpath', and
* register an instance using 'parameters'.
* context, respectively; they are passed as void * here in order to
* prevent this library from having a dependency on libisccfg).
*
- * 'hctx' is the hook context and 'hooktable' is the hook table
- * into which hook points should be registered.
- *
* 'instp' will be left pointing to the instance of the module
* created by the module's hook_register function.
*/
isc_result_t
ns_module_check(const char *modpath, const char *parameters,
- const char *cfg_file, unsigned long cfg_line,
- const void *cfg, isc_mem_t *mctx, isc_log_t *lctx, void *actx);
+ const void *cfg, const char *cfg_file, unsigned long cfg_line,
+ isc_mem_t *mctx, isc_log_t *lctx, void *actx);
/*%<
* Open the module at 'modpath' and check the validity of
* 'parameters', logging any errors or warnings found, then
ns_clientmgr_createclients
ns_clientmgr_destroy
ns_hook_add
-ns_hook_createctx
-ns_hook_destroyctx
ns_hooktable_create
ns_hooktable_free
ns_hooktable_init