Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include <signal.h>
#include <unbound.h>
#include <arpa/nameser.h>
#include "asterisk/module.h"
#include "asterisk/linkedlists.h"
#include "asterisk/dns_core.h"
#include "asterisk/dns_resolver.h"
#include "asterisk/config.h"
#include "asterisk/config_options.h"
#include "asterisk/test.h"
Go to the source code of this file.
Data Structures | |
struct | unbound_config |
A container for config related information. More... | |
struct | unbound_config_state |
Unbound configuration state information. More... | |
struct | unbound_global_config |
A structure to hold global configuration-related options. More... | |
struct | unbound_resolver |
Structure for an unbound resolver. More... | |
struct | unbound_resolver_data |
Structure for query resolver data. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static | AO2_GLOBAL_OBJ_STATIC (globals) |
A global object container that will contain the global_config that gets swapped out on reloads. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
CONFIG_INFO_STANDARD (cfg_info, globals, unbound_config_alloc,.files=ACO_FILES(&resolver_unbound_conf),.pre_apply_config=unbound_config_preapply_callback,) | |
Register information about the configs being processed by this module. More... | |
static int | custom_nameserver_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | load_module (void) |
static int | reload_module (void) |
static void * | unbound_config_alloc (void) |
Allocate a unbound_config to hold a snapshot of the complete results of parsing a config. More... | |
static int | unbound_config_apply_default (void) |
static void | unbound_config_destructor (void *obj) |
static int | unbound_config_preapply (struct unbound_config *cfg) |
static int | unbound_config_preapply_callback (void) |
Finish initializing new configuration. More... | |
static void | unbound_config_state_destructor (void *obj) |
static void | unbound_global_config_destructor (void *obj) |
static struct unbound_resolver * | unbound_resolver_alloc (void) |
Allocator for unbound resolver. More... | |
static void | unbound_resolver_callback (void *data, int err, struct ub_result *ub_result) |
Callback invoked when resolution completes on a query. More... | |
static int | unbound_resolver_cancel (struct ast_dns_query *query) |
static void | unbound_resolver_data_dtor (void *vdoomed) |
static void | unbound_resolver_destroy (void *obj) |
Destructor for unbound resolver. More... | |
static int | unbound_resolver_resolve (struct ast_dns_query *query) |
static int | unbound_resolver_start (struct unbound_resolver *resolver) |
Start function for the unbound resolver. More... | |
static void | unbound_resolver_stop (struct unbound_resolver *resolver) |
Stop function for the unbound resolver. More... | |
static void * | unbound_resolver_thread (void *data) |
Resolver thread which waits and handles results. More... | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Unbound DNS Resolver Support" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 4, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct aco_type | global_option |
An aco_type structure to link the "general" category to the unbound_global_config type. More... | |
static struct aco_type * | global_options [] = ACO_TYPES(&global_option) |
static struct aco_file | resolver_unbound_conf |
struct ast_dns_resolver | unbound_resolver |
|
static |
Definition at line 1489 of file res_resolver_unbound.c.
|
static |
Definition at line 1489 of file res_resolver_unbound.c.
|
static |
A global object container that will contain the global_config that gets swapped out on reloads.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1489 of file res_resolver_unbound.c.
CONFIG_INFO_STANDARD | ( | cfg_info | , |
globals | , | ||
unbound_config_alloc | , | ||
. | files = ACO_FILES(&resolver_unbound_conf) , |
||
. | pre_apply_config = unbound_config_preapply_callback |
||
) |
Register information about the configs being processed by this module.
|
static |
Definition at line 1424 of file res_resolver_unbound.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ast_str_container_add(), ast_str_container_alloc_options(), global, and var.
Referenced by load_module().
|
static |
Definition at line 1438 of file res_resolver_unbound.c.
References ACO_EXACT, aco_info_init(), aco_option_register, aco_option_register_custom, aco_process_config(), ACO_PROCESS_ERROR, ast_config_destroy(), ast_config_load, ast_dns_resolver_register(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_module_shutdown_ref, AST_TEST_REGISTER, custom_nameserver_handler(), debug, aco_file::filename, FLDSET, global_options, OPT_STRINGFIELD_T, OPT_UINT_T, resolver_unbound_conf, ast_module_info::self, STRFLDSET, unbound_config_apply_default(), and unload_module().
|
static |
Definition at line 1400 of file res_resolver_unbound.c.
References aco_process_config(), ACO_PROCESS_ERROR, and AST_MODULE_RELOAD_ERROR.
|
static |
Allocate a unbound_config to hold a snapshot of the complete results of parsing a config.
Definition at line 373 of file res_resolver_unbound.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_string_field_init, error(), unbound_config::global, NULL, unbound_config_destructor(), and unbound_global_config_destructor().
Referenced by unbound_config_apply_default().
|
static |
Definition at line 480 of file res_resolver_unbound.c.
References aco_set_defaults(), ao2_global_obj_replace_unref, ao2_ref, ast_log, ast_verb, unbound_config::global, global_option, globals, LOG_ERROR, unbound_config_alloc(), and unbound_config_preapply().
Referenced by load_module().
|
static |
Definition at line 347 of file res_resolver_unbound.c.
References ao2_cleanup, and unbound_config::global.
Referenced by unbound_config_alloc().
|
static |
Definition at line 399 of file res_resolver_unbound.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_log, ast_strlen_zero(), unbound_resolver::context, unbound_global_config::debug, unbound_config::global, unbound_global_config::hosts, LOG_ERROR, unbound_global_config::nameservers, NULL, unbound_global_config::resolv, unbound_config_state::resolver, unbound_global_config::state, unbound_global_config::ta_file, unbound_config_state_destructor(), unbound_resolver_alloc(), and unbound_resolver_start().
Referenced by unbound_config_apply_default(), and unbound_config_preapply_callback().
|
static |
Finish initializing new configuration.
Definition at line 505 of file res_resolver_unbound.c.
References aco_pending_config(), and unbound_config_preapply().
|
static |
Definition at line 363 of file res_resolver_unbound.c.
References ao2_ref, and unbound_resolver_stop().
Referenced by unbound_config_preapply().
|
static |
Definition at line 354 of file res_resolver_unbound.c.
References ao2_cleanup, ast_string_field_free_memory, and global.
Referenced by unbound_config_alloc().
|
static |
Allocator for unbound resolver.
Definition at line 171 of file res_resolver_unbound.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, AST_PTHREADT_NULL, unbound_resolver::context, NULL, unbound_resolver::thread, and unbound_resolver_destroy().
Referenced by unbound_config_preapply().
|
static |
Callback invoked when resolution completes on a query.
Definition at line 256 of file res_resolver_unbound.c.
References ao2_ref, ast_debug, ast_dns_query_get_name(), ast_dns_resolver_add_record(), ast_dns_resolver_completed(), ast_dns_resolver_set_result(), and S_OR.
Referenced by unbound_resolver_resolve().
|
static |
Definition at line 324 of file res_resolver_unbound.c.
References ao2_ref, ast_dns_resolver_get_data(), unbound_resolver::context, unbound_resolver_data::id, and unbound_resolver_data::resolver.
|
static |
Definition at line 286 of file res_resolver_unbound.c.
References ao2_cleanup, and unbound_resolver_data::resolver.
Referenced by unbound_resolver_resolve().
|
static |
Destructor for unbound resolver.
Definition at line 161 of file res_resolver_unbound.c.
References unbound_resolver::context.
Referenced by unbound_resolver_alloc().
|
static |
Definition at line 293 of file res_resolver_unbound.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ao2_global_obj_ref, ao2_ref, ast_dns_query_get_name(), ast_dns_query_get_rr_class(), ast_dns_query_get_rr_type(), ast_dns_resolver_set_data(), ast_log, unbound_resolver::context, unbound_config::global, globals, unbound_resolver_data::id, LOG_ERROR, unbound_resolver_data::resolver, unbound_config_state::resolver, unbound_global_config::state, unbound_resolver_callback(), and unbound_resolver_data_dtor().
|
static |
Start function for the unbound resolver.
Definition at line 217 of file res_resolver_unbound.c.
References ao2_bump, ao2_ref, ast_debug, ast_pthread_create, AST_PTHREADT_NULL, NULL, unbound_resolver::thread, and unbound_resolver_thread().
Referenced by unbound_config_preapply().
|
static |
Stop function for the unbound resolver.
Definition at line 237 of file res_resolver_unbound.c.
References ast_debug, AST_PTHREADT_NULL, AST_PTHREADT_STOP, NULL, thread, and unbound_resolver::thread.
Referenced by unbound_config_state_destructor().
|
static |
Resolver thread which waits and handles results.
Definition at line 195 of file res_resolver_unbound.c.
References ao2_ref, ast_debug, AST_PTHREADT_STOP, ast_wait_for_input(), unbound_resolver::context, NULL, and unbound_resolver::thread.
Referenced by unbound_resolver_start().
|
static |
Definition at line 1409 of file res_resolver_unbound.c.
References aco_info_destroy(), ao2_global_obj_release, AST_TEST_UNREGISTER, and globals.
Referenced by load_module().
|
static |
Definition at line 1489 of file res_resolver_unbound.c.
|
static |
Definition at line 1489 of file res_resolver_unbound.c.
|
static |
An aco_type structure to link the "general" category to the unbound_global_config type.
Definition at line 130 of file res_resolver_unbound.c.
Referenced by unbound_config_apply_default().
|
static |
Definition at line 138 of file res_resolver_unbound.c.
Referenced by load_module().
|
static |
Definition at line 140 of file res_resolver_unbound.c.
Referenced by load_module().
struct ast_dns_resolver unbound_resolver |
Definition at line 340 of file res_resolver_unbound.c.