Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/vector.h"
#include "asterisk/dns_core.h"
#include "asterisk/dns_resolver.h"
#include "asterisk/dns_query_set.h"
#include "asterisk/dns_internal.h"
Go to the source code of this file.
Data Structures | |
struct | query_set_data |
Macros | |
#define | DNS_ANSWER "Yes sirree" |
#define | DNS_ANSWER_SIZE strlen(DNS_ANSWER) |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (query_set) | |
AST_TEST_DEFINE (query_set_empty) | |
AST_TEST_DEFINE (query_set_nominal_cancel) | |
AST_TEST_DEFINE (query_set_off_nominal_cancel) | |
static int | load_module (void) |
static void | query_set_callback (const struct ast_dns_query_set *query_set) |
Callback which is invoked upon query set completion. More... | |
static int | query_set_cancel (struct ast_dns_query *query) |
Resolver's cancel() method. More... | |
static struct query_set_data * | query_set_data_alloc (void) |
static void | query_set_data_destructor (void *obj) |
static int | query_set_resolve (struct ast_dns_query *query) |
Resolver's resolve() method. More... | |
static enum ast_test_result_state | query_set_test (struct ast_test *test, int resolve, int cancel) |
Framework for running a query set DNS test. More... | |
static void * | resolution_thread (void *dns_query) |
Thread that performs asynchronous resolution. More... | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "DNS query set tests" , .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, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_dns_resolver | query_set_resolver |
#define DNS_ANSWER "Yes sirree" |
Definition at line 75 of file test_dns_query_set.c.
Referenced by resolution_thread().
#define DNS_ANSWER_SIZE strlen(DNS_ANSWER) |
Definition at line 76 of file test_dns_query_set.c.
Referenced by resolution_thread().
|
static |
Definition at line 392 of file test_dns_query_set.c.
|
static |
Definition at line 392 of file test_dns_query_set.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 392 of file test_dns_query_set.c.
AST_TEST_DEFINE | ( | query_set | ) |
Definition at line 287 of file test_dns_query_set.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), query_set_test(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | query_set_empty | ) |
Definition at line 309 of file test_dns_query_set.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), query_set_test(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | query_set_nominal_cancel | ) |
Definition at line 329 of file test_dns_query_set.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), query_set_test(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | query_set_off_nominal_cancel | ) |
Definition at line 350 of file test_dns_query_set.c.
References AST_TEST_NOT_RUN, sip_to_pjsip::info(), query_set_test(), TEST_EXECUTE, and TEST_INIT.
|
static |
Definition at line 382 of file test_dns_query_set.c.
References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.
|
static |
Callback which is invoked upon query set completion.
query_set | The query set |
Definition at line 161 of file test_dns_query_set.c.
References ast_cond_signal, ast_dns_query_set_get_data(), ast_mutex_lock, ast_mutex_unlock, query_set_data::cond, query_set_data::lock, and query_set_data::query_set_complete.
Referenced by query_set_test().
|
static |
Resolver's cancel() method.
query | The query to cancel |
Definition at line 131 of file test_dns_query_set.c.
References ast_dns_query_get_data(), query_set_data::cancel, query_set_data::cancel_allowed, and ast_dns_query_set::user_data.
|
static |
Definition at line 60 of file test_dns_query_set.c.
References ao2_alloc, ast_cond_init, ast_mutex_init, query_set_data::cond, query_set_data::lock, NULL, and query_set_data_destructor().
Referenced by query_set_test().
|
static |
Definition at line 52 of file test_dns_query_set.c.
References ast_cond_destroy, ast_mutex_destroy, query_set_data::cond, and query_set_data::lock.
Referenced by query_set_data_alloc().
|
static |
Resolver's resolve() method.
query | The query that is to be resolved |
0 | Successfully created thread to perform the resolution |
non-zero | Failed to create resolution thread |
Definition at line 111 of file test_dns_query_set.c.
References ao2_bump, ast_dns_query_get_data(), ast_pthread_create_detached, query_set_data::cancel_allowed, NULL, resolution_thread(), query_set_data::resolves, and ast_dns_query_set::user_data.
|
static |
Framework for running a query set DNS test.
This function serves as a common way of testing various numbers of queries in a query set and optional canceling of them.
test | The test being run |
resolve | The number of queries that should be allowed to complete resolution |
cancel | The number of queries that should be allowed to be canceled |
Definition at line 181 of file test_dns_query_set.c.
References ao2_cleanup, ast_cond_timedwait, ast_dns_query_get_name(), ast_dns_query_get_rr_class(), ast_dns_query_get_rr_type(), ast_dns_query_set_add(), ast_dns_query_set_create(), ast_dns_query_set_get(), ast_dns_query_set_num_queries(), ast_dns_query_set_resolve_async(), ast_dns_query_set_resolve_cancel(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, ast_tsnow(), query_set_data::cancel, cleanup(), NULL, query_set_callback(), query_set_data_alloc(), RAII_VAR, and total.
Referenced by AST_TEST_DEFINE().
|
static |
Thread that performs asynchronous resolution.
This thread uses the query's user data to determine how to perform the resolution. If the allowed number of resolutions has not been reached then this will succeed, otherwise the query is expected to have been canceled.
dns_query | The ast_dns_query that is being performed |
Definition at line 89 of file test_dns_query_set.c.
References ao2_ref, ast_assert, ast_dns_query_get_data(), ast_dns_resolver_completed(), ast_dns_resolver_set_result(), DNS_ANSWER, DNS_ANSWER_SIZE, NULL, and ast_dns_query_set::user_data.
Referenced by query_set_resolve().
|
static |
|
static |
Definition at line 392 of file test_dns_query_set.c.
|
static |
Definition at line 392 of file test_dns_query_set.c.
|
static |
Definition at line 149 of file test_dns_query_set.c.