Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include <arpa/nameser.h>
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/dns_core.h"
#include "asterisk/dns_resolver.h"
#include "asterisk/dns_naptr.h"
#include "asterisk/dns_test.h"
Go to the source code of this file.
Data Structures | |
struct | naptr_record |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (naptr_resolve_nominal) | |
AST_TEST_DEFINE (naptr_resolve_off_nominal_flags) | |
AST_TEST_DEFINE (naptr_resolve_off_nominal_interactions) | |
AST_TEST_DEFINE (naptr_resolve_off_nominal_length) | |
AST_TEST_DEFINE (naptr_resolve_off_nominal_regexp) | |
AST_TEST_DEFINE (naptr_resolve_off_nominal_services) | |
static int | generate_naptr_record (void *dns_record, char *buf) |
Given a NAPTR record, generate a binary form, as would appear in DNS RDATA. More... | |
static int | load_module (void) |
static int | naptr_cancel (struct ast_dns_query *query) |
A STUB. More... | |
static int | naptr_resolve (struct ast_dns_query *query) |
Mock NAPTR resolution method. More... | |
static void * | naptr_thread (void *dns_query) |
Asynchronous NAPTR resolution thread. More... | |
static enum ast_test_result_state | off_nominal_test (struct ast_test *test, struct naptr_record *records, int num_records) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "DNS API 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 char | ans_buffer [1024] |
A buffer to place raw DNS records into. More... | |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_dns_resolver | naptr_resolver |
Mock NAPTR resolver. More... | |
static int | num_test_records |
The number of records in the test_records array. More... | |
static struct naptr_record * | test_records |
A pointer to an array of records for a test. More... | |
|
static |
Definition at line 502 of file test_dns_naptr.c.
|
static |
Definition at line 502 of file test_dns_naptr.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 502 of file test_dns_naptr.c.
AST_TEST_DEFINE | ( | naptr_resolve_nominal | ) |
Definition at line 165 of file test_dns_naptr.c.
References ans_buffer, ARRAY_LEN, ast_dns_naptr_get_flags(), ast_dns_naptr_get_order(), ast_dns_naptr_get_preference(), ast_dns_naptr_get_regexp(), ast_dns_naptr_get_replacement(), ast_dns_naptr_get_service(), ast_dns_record_get_next(), ast_dns_resolve(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), ast_dns_result_free(), ast_dns_result_get_records(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, cleanup(), naptr_record::flags, sip_to_pjsip::info(), naptr_resolver, NULL, num_test_records, order, naptr_record::preference, RAII_VAR, records, naptr_record::regexp, naptr_record::replacement, result, naptr_record::services, TEST_EXECUTE, TEST_INIT, test_records, and ast_dns_test_string::val.
AST_TEST_DEFINE | ( | naptr_resolve_off_nominal_flags | ) |
Definition at line 346 of file test_dns_naptr.c.
References ARRAY_LEN, AST_TEST_NOT_RUN, sip_to_pjsip::info(), off_nominal_test(), records, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | naptr_resolve_off_nominal_interactions | ) |
Definition at line 452 of file test_dns_naptr.c.
References ARRAY_LEN, AST_TEST_NOT_RUN, sip_to_pjsip::info(), off_nominal_test(), records, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | naptr_resolve_off_nominal_length | ) |
Definition at line 316 of file test_dns_naptr.c.
References ARRAY_LEN, AST_TEST_NOT_RUN, sip_to_pjsip::info(), off_nominal_test(), records, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | naptr_resolve_off_nominal_regexp | ) |
Definition at line 417 of file test_dns_naptr.c.
References ARRAY_LEN, AST_TEST_NOT_RUN, sip_to_pjsip::info(), off_nominal_test(), records, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | naptr_resolve_off_nominal_services | ) |
Definition at line 386 of file test_dns_naptr.c.
References ARRAY_LEN, AST_TEST_NOT_RUN, sip_to_pjsip::info(), off_nominal_test(), records, TEST_EXECUTE, and TEST_INIT.
|
static |
Given a NAPTR record, generate a binary form, as would appear in DNS RDATA.
This is part of a DNS answer, specific to NAPTR. It consists of all parts of the NAPTR record, encoded as it should be in a DNS record.
There is no buffer size passed to this function since we provide the data ourselves and have sized the buffer to be way larger than necessary for the tests.
dns_record | The NAPTR record to encode |
buf | The buffer to write the record into |
Definition at line 58 of file test_dns_naptr.c.
References ast_dns_test_write_domain(), ast_dns_test_write_string(), buf, naptr_record::flags, naptr_record::order, naptr_record::preference, naptr_record::regexp, naptr_record::replacement, and naptr_record::services.
Referenced by naptr_thread().
|
static |
Definition at line 490 of file test_dns_naptr.c.
References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.
|
static |
|
static |
Mock NAPTR resolution method.
This spawns a thread to handle generation of the necessary NAPTR records
Definition at line 140 of file test_dns_naptr.c.
References ao2_bump, ast_pthread_create_detached, naptr_thread(), NULL, and thread.
|
static |
Asynchronous NAPTR resolution thread.
This builds an appropriate DNS response based on the NAPTR records for a given test. Once the records have been created, the records are added to the DNS result
Definition at line 110 of file test_dns_naptr.c.
References ans_buffer, ao2_ref, ast_dns_resolver_add_record(), ast_dns_resolver_completed(), ast_dns_resolver_set_result(), ast_dns_test_generate_result(), generate_naptr_record(), NULL, num_test_records, and test_records.
Referenced by naptr_resolve().
|
static |
Definition at line 275 of file test_dns_naptr.c.
References ans_buffer, ast_dns_resolve(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), ast_dns_result_free(), ast_dns_result_get_records(), AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, cleanup(), naptr_resolver, NULL, num_test_records, RAII_VAR, records, result, and test_records.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 478 of file test_dns_naptr.c.
References AST_TEST_UNREGISTER.
|
static |
Definition at line 502 of file test_dns_naptr.c.
|
static |
A buffer to place raw DNS records into.
This buffer is way larger than any DNS records we actually wish to create during any of the tests, but that's fine.
Definition at line 101 of file test_dns_naptr.c.
Referenced by AST_TEST_DEFINE(), naptr_thread(), and off_nominal_test().
|
static |
Definition at line 502 of file test_dns_naptr.c.
|
static |
Mock NAPTR resolver.
Definition at line 158 of file test_dns_naptr.c.
Referenced by AST_TEST_DEFINE(), and off_nominal_test().
|
static |
The number of records in the test_records array.
Each test must set this to the appropriate value at the beginning of the test and must set this back to zero at the end of the test.
Definition at line 94 of file test_dns_naptr.c.
Referenced by AST_TEST_DEFINE(), naptr_thread(), and off_nominal_test().
|
static |
A pointer to an array of records for a test.
Each test is expected to set this pointer to its local array of records and then re-set tis pointer to NULL at the end of the test
Definition at line 86 of file test_dns_naptr.c.
Referenced by AST_TEST_DEFINE(), naptr_thread(), and off_nominal_test().