Asterisk - The Open Source Telephony Project
18.5.0
|
DNS Query Set API. More...
#include "asterisk.h"
#include "asterisk/vector.h"
#include "asterisk/astobj2.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/dns_core.h"
#include "asterisk/dns_query_set.h"
#include "asterisk/dns_internal.h"
#include "asterisk/dns_resolver.h"
Go to the source code of this file.
Data Structures | |
struct | dns_synchronous_resolve |
Structure used for signaling back for synchronous resolution completion. More... | |
Macros | |
#define | DNS_QUERY_SET_EXPECTED_QUERY_COUNT 5 |
The default number of expected queries to be added to the query set. More... | |
Functions | |
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. More... | |
struct ast_dns_query_set * | ast_dns_query_set_create (void) |
Create a query set to hold queries. More... | |
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. More... | |
void * | ast_dns_query_set_get_data (const struct ast_dns_query_set *query_set) |
Retrieve user specific data from a query set. More... | |
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. More... | |
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. More... | |
int | ast_dns_query_set_resolve_cancel (struct ast_dns_query_set *query_set) |
Cancel an asynchronous DNS query set resolution. More... | |
int | ast_query_set_resolve (struct ast_dns_query_set *query_set) |
Synchronously resolve queries in a query set. More... | |
static void | dns_query_set_callback (const struct ast_dns_query *query) |
Callback invoked upon completion of a DNS query. More... | |
static void | dns_query_set_destroy (void *data) |
Destructor for DNS query set. More... | |
static void | dns_synchronous_resolve_callback (const struct ast_dns_query_set *query_set) |
Callback used to implement synchronous resolution. More... | |
static void | dns_synchronous_resolve_destroy (void *data) |
Destructor for synchronous resolution structure. More... | |
DNS Query Set API.
Definition in file dns_query_set.c.
#define DNS_QUERY_SET_EXPECTED_QUERY_COUNT 5 |
The default number of expected queries to be added to the query set.
Definition at line 42 of file dns_query_set.c.
Referenced by ast_dns_query_set_create().
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.
query_set | A DNS query set |
name | The name of what to resolve |
rr_type | Resource record type |
rr_class | Resource record class |
0 | success |
-1 | failure |
Definition at line 105 of file dns_query_set.c.
References ao2_ref, ast_assert, ast_log, AST_VECTOR_APPEND, dns_query_alloc(), dns_query_set_callback(), ast_dns_query_set::in_progress, LOG_ERROR, NULL, dns_query_set_query::query, and dns_query_set_query::started.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), query_set_test(), and sip_resolve_add().
struct ast_dns_query_set* ast_dns_query_set_create | ( | void | ) |
Create a query set to hold queries.
non-NULL | success |
NULL | failure |
Definition at line 60 of file dns_query_set.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, AST_VECTOR_INIT, dns_query_set_destroy(), DNS_QUERY_SET_EXPECTED_QUERY_COUNT, and NULL.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), query_set_test(), and sip_resolve_add().
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.
query_set | A DNS query set |
index | The index of the query to retrieve |
non-NULL | success |
NULL | failure |
Definition at line 144 of file dns_query_set.c.
References AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, NULL, and ast_dns_query_set::queries_completed.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), query_set_test(), and sip_resolve_callback().
void* ast_dns_query_set_get_data | ( | const struct ast_dns_query_set * | query_set | ) |
Retrieve user specific data from a query set.
query_set | A DNS query set |
Definition at line 159 of file dns_query_set.c.
References ast_dns_query_set::user_data.
Referenced by dns_synchronous_resolve_callback(), query_set_callback(), and sip_resolve_callback().
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.
query_set | A DNS query set |
Definition at line 139 of file dns_query_set.c.
References AST_VECTOR_SIZE.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), query_set_test(), and sip_resolve_callback().
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.
query_set | The query set |
callback | The callback to invoke upon completion |
data | User data to make available on the query set |
Definition at line 164 of file dns_query_set.c.
References ao2_bump, ao2_cleanup, ao2_ref, ast_assert, ast_log, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, ast_dns_query::callback, ast_dns_query_set::callback, dns_synchronous_resolve::completed, dns_synchronous_resolve::cond, dns_query_set_callback(), ast_dns_query_set::in_progress, dns_synchronous_resolve::lock, LOG_ERROR, NULL, dns_query_set_query::query, ast_dns_resolver::resolve, ast_dns_query::resolver, dns_query_set_query::started, ast_dns_query::user_data, and ast_dns_query_set::user_data.
Referenced by ast_query_set_resolve(), query_set_test(), sip_resolve(), and sip_resolve_callback().
int ast_dns_query_set_resolve_cancel | ( | struct ast_dns_query_set * | query_set | ) |
Cancel an asynchronous DNS query set resolution.
query_set | The DNS query set |
0 | success (all queries have been cancelled) |
-1 | failure (some queries could not be cancelled) |
Definition at line 265 of file dns_query_set.c.
References AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, ast_dns_resolver::cancel, dns_query_set_callback(), ast_dns_query_set::queries_cancelled, dns_query_set_query::query, ast_dns_query::resolver, and dns_query_set_query::started.
Referenced by query_set_test().
int ast_query_set_resolve | ( | struct ast_dns_query_set * | query_set | ) |
Synchronously resolve queries in a query set.
query_set | The query set |
0 | success |
-1 | failure |
Definition at line 239 of file dns_query_set.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_cond_init, ast_cond_wait, ast_dns_query_set_resolve_async(), ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, dns_synchronous_resolve::completed, dns_synchronous_resolve::cond, dns_synchronous_resolve_callback(), dns_synchronous_resolve_destroy(), dns_synchronous_resolve::lock, and NULL.
Referenced by ast_dns_resolve_ipv6_and_ipv4().
|
static |
Callback invoked upon completion of a DNS query.
Definition at line 78 of file dns_query_set.c.
References ao2_cleanup, ao2_ref, ast_atomic_fetchadd_int(), ast_dns_query_get_data(), AST_VECTOR_SIZE, ast_dns_query_set::callback, NULL, ast_dns_query_set::queries_cancelled, ast_dns_query_set::queries_completed, and ast_dns_query_set::user_data.
Referenced by ast_dns_query_set_add(), ast_dns_query_set_resolve_async(), and ast_dns_query_set_resolve_cancel().
|
static |
Destructor for DNS query set.
Definition at line 45 of file dns_query_set.c.
References ao2_cleanup, ao2_ref, AST_VECTOR_FREE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, dns_query_set_query::query, and ast_dns_query_set::user_data.
Referenced by ast_dns_query_set_create().
|
static |
Callback used to implement synchronous resolution.
Definition at line 229 of file dns_query_set.c.
References ast_cond_signal, ast_dns_query_set_get_data(), ast_mutex_lock, ast_mutex_unlock, dns_synchronous_resolve::completed, dns_synchronous_resolve::cond, and dns_synchronous_resolve::lock.
Referenced by ast_query_set_resolve().
|
static |
Destructor for synchronous resolution structure.
Definition at line 220 of file dns_query_set.c.
References ast_cond_destroy, ast_mutex_destroy, dns_synchronous_resolve::cond, and dns_synchronous_resolve::lock.
Referenced by ast_query_set_resolve().