| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
#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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| static void | unbound_resolver_callback (void *data, int err, struct ub_result *ub_result) | 
| Callback invoked when resolution completes on a query. | |
| 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. | |
| 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. | |
| static void | unbound_resolver_stop (struct unbound_resolver *resolver) | 
| Stop function for the unbound resolver. | |
| static void * | unbound_resolver_thread (void *data) | 
| Resolver thread which waits and handles results. | |
| 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 = ASTERISK_GPL_KEY , .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. | |
| 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 1507 of file res_resolver_unbound.c.
| 
 | static | 
Definition at line 1507 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 1507 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 1442 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 1456 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 1418 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 391 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 498 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 365 of file res_resolver_unbound.c.
References ao2_cleanup, and unbound_config::global.
Referenced by unbound_config_alloc().
| 
 | static | 
Definition at line 417 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 523 of file res_resolver_unbound.c.
References aco_pending_config(), and unbound_config_preapply().
| 
 | static | 
Definition at line 381 of file res_resolver_unbound.c.
References ao2_ref, and unbound_resolver_stop().
Referenced by unbound_config_preapply().
| 
 | static | 
Definition at line 372 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 189 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 274 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 342 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 304 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 179 of file res_resolver_unbound.c.
References unbound_resolver::context.
Referenced by unbound_resolver_alloc().
| 
 | static | 
Definition at line 311 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 235 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 255 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 213 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 1427 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 1507 of file res_resolver_unbound.c.
| 
 | static | 
Definition at line 1507 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 148 of file res_resolver_unbound.c.
Referenced by unbound_config_apply_default().
| 
 | static | 
Definition at line 156 of file res_resolver_unbound.c.
Referenced by load_module().
| 
 | static | 
Definition at line 158 of file res_resolver_unbound.c.
Referenced by load_module().
| struct ast_dns_resolver unbound_resolver | 
Definition at line 358 of file res_resolver_unbound.c.