26#include <arpa/nameser.h> 
   75#define DNS_ANSWER "Yes sirree" 
   76#define DNS_ANSWER_SIZE strlen(DNS_ANSWER) 
  115    pthread_t resolver_thread;
 
 
  188    struct timespec timeout;
 
  209    qsdata->resolves_allowed = resolve;
 
  210    qsdata->cancel_allowed = cancel;
 
  212    for (idx = 0; idx < 
total; ++idx) {
 
  228    if (cancel && (cancel == 
total)) {
 
  234        if (qsdata->query_set_complete) {
 
  249    timeout.tv_sec += 10;
 
  252    while (!qsdata->query_set_complete) {
 
  259    if (!qsdata->query_set_complete) {
 
 
  291        info->name = 
"query_set";
 
  292        info->category = 
"/main/dns/query_set/";
 
  293        info->summary = 
"Test nominal asynchronous DNS query set";
 
  295            "This tests nominal query set in the following ways:\n" 
  296            "\t* Multiple queries are added to a query set\n" 
  297            "\t* The mock resolver is configured to respond to all queries\n" 
  298            "\t* Asynchronous resolution of the query set is started\n" 
  299            "\t* The mock resolver responds to all queries\n" 
  300            "\t* We ensure that the query set callback is invoked upon completion";
 
 
  313        info->name = 
"query_set_empty";
 
  314        info->category = 
"/main/dns/query_set/";
 
  315        info->summary = 
"Test nominal asynchronous empty DNS query set";
 
  317            "This tests nominal query set in the following ways:\n" 
  318            "\t* No queries are added to a query set\n" 
  319            "\t* Asynchronous resolution of the query set is started\n" 
  320            "\t* We ensure that the query set callback is invoked upon completion";
 
 
  333        info->name = 
"query_set_nominal_cancel";
 
  334        info->category = 
"/main/dns/query_set/";
 
  335        info->summary = 
"Test nominal asynchronous DNS query set cancellation";
 
  337            "This tests nominal query set cancellation in the following ways:\n" 
  338            "\t* Multiple queries are added to a query set\n" 
  339            "\t* The mock resolver is configured to NOT respond to any queries\n" 
  340            "\t* Asynchronous resolution of the query set is started\n" 
  341            "\t* The query set is canceled and is confirmed to return with success";
 
 
  354        info->name = 
"query_set_off_nominal_cancel";
 
  355        info->category = 
"/main/dns/query_set/";
 
  356        info->summary = 
"Test off-nominal asynchronous DNS query set cancellation";
 
  358            "This tests nominal query set cancellation in the following ways:\n" 
  359            "\t* Multiple queries are added to a query set\n" 
  360            "\t* The mock resolver is configured to respond to half the queries\n" 
  361            "\t* Asynchronous resolution of the query set is started\n" 
  362            "\t* The query set is canceled and is confirmed to return failure\n" 
  363            "\t* The query set callback is confirmed to run, since it could not be fully canceled";
 
 
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define ao2_alloc(data_size, destructor_fn)
int ast_dns_query_get_rr_type(const struct ast_dns_query *query)
Get the record resource type of a DNS query.
int ast_dns_query_get_rr_class(const struct ast_dns_query *query)
Get the record resource class of a DNS query.
void * ast_dns_query_get_data(const struct ast_dns_query *query)
Get the user specific data of a DNS query.
const char * ast_dns_query_get_name(const struct ast_dns_query *query)
Get the name queried in a DNS query.
Internal DNS structure definitions.
struct ast_dns_query * ast_dns_query_set_get(const struct ast_dns_query_set *query_set, unsigned int index)
Retrieve a query from a query set.
struct ast_dns_query_set * ast_dns_query_set_create(void)
Create a query set to hold queries.
size_t ast_dns_query_set_num_queries(const struct ast_dns_query_set *query_set)
Retrieve the number of queries in a query set.
int ast_dns_query_set_add(struct ast_dns_query_set *query_set, const char *name, int rr_type, int rr_class)
Add a query to a query set.
int ast_dns_query_set_resolve_cancel(struct ast_dns_query_set *query_set)
Cancel an asynchronous DNS query set resolution.
void ast_dns_query_set_resolve_async(struct ast_dns_query_set *query_set, ast_dns_query_set_callback callback, void *data)
Asynchronously resolve queries in a query set.
void * ast_dns_query_set_get_data(const struct ast_dns_query_set *query_set)
Retrieve user specific data from a query set.
int ast_dns_resolver_set_result(struct ast_dns_query *query, unsigned int secure, unsigned int bogus, unsigned int rcode, const char *canonical, const char *answer, size_t answer_size)
Set result information for a DNS query.
void ast_dns_resolver_completed(struct ast_dns_query *query)
Mark a DNS query as having been completed.
int ast_dns_resolver_register(struct ast_dns_resolver *resolver)
Register a DNS resolver.
void ast_dns_resolver_unregister(struct ast_dns_resolver *resolver)
Unregister a DNS resolver.
#define ast_cond_destroy(cond)
#define ast_cond_init(cond, attr)
#define ast_cond_timedwait(cond, mutex, time)
#define ast_mutex_init(pmutex)
#define ast_mutex_unlock(a)
pthread_cond_t ast_cond_t
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define ast_cond_signal(cond)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
static void cleanup(void)
Clean up any old apps that we don't need any more.
void * user_data
User-specific data.
DNS resolver implementation.
const char * name
The name of the resolver implementation.
Structure for mutex and tracking information.
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
static struct ast_dns_resolver query_set_resolver
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.
static int query_set_cancel(struct ast_dns_query *query)
Resolver's cancel() method.
static struct query_set_data * query_set_data_alloc(void)
static void query_set_data_destructor(void *obj)
static void * resolution_thread(void *dns_query)
Thread that performs asynchronous resolution.
static void query_set_callback(const struct ast_dns_query_set *query_set)
Callback which is invoked upon query set completion.
static int load_module(void)
static int unload_module(void)
static int query_set_resolve(struct ast_dns_query *query)
Resolver's resolve() method.
struct timespec ast_tsnow(void)
Returns current timespec. Meant to avoid calling ast_tvnow() just to create a timespec from the timev...
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_pthread_create_detached(a, b, c, d)
Vector container support.