Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Core DNS API. More...
#include "asterisk/netsock2.h"
Go to the source code of this file.
Typedefs | |
typedef void(* | ast_dns_resolve_callback) (const struct ast_dns_query *query) |
Callback invoked when a query completes. More... | |
Functions | |
void * | ast_dns_query_get_data (const struct ast_dns_query *query) |
Get the user specific data of a DNS query. More... | |
const char * | ast_dns_query_get_name (const struct ast_dns_query *query) |
Get the name queried in a DNS query. More... | |
struct ast_dns_result * | ast_dns_query_get_result (const struct ast_dns_query *query) |
Get the result information for a DNS query. More... | |
int | ast_dns_query_get_rr_class (const struct ast_dns_query *query) |
Get the record resource class of a DNS query. More... | |
int | ast_dns_query_get_rr_type (const struct ast_dns_query *query) |
Get the record resource type of a DNS query. More... | |
const char * | ast_dns_record_get_data (const struct ast_dns_record *record) |
Retrieve the raw DNS record. More... | |
size_t | ast_dns_record_get_data_size (const struct ast_dns_record *record) |
Retrieve the size of the raw DNS record. More... | |
const struct ast_dns_record * | ast_dns_record_get_next (const struct ast_dns_record *record) |
Get the next DNS record. More... | |
int | ast_dns_record_get_rr_class (const struct ast_dns_record *record) |
Get the resource record class of a DNS record. More... | |
int | ast_dns_record_get_rr_type (const struct ast_dns_record *record) |
Get the resource record type of a DNS record. More... | |
int | ast_dns_record_get_ttl (const struct ast_dns_record *record) |
Get the TTL of a DNS record. More... | |
int | ast_dns_resolve (const char *name, int rr_type, int rr_class, struct ast_dns_result **result) |
Synchronously resolve a DNS query. More... | |
struct ast_dns_query_active * | ast_dns_resolve_async (const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data) |
Asynchronously resolve a DNS query. More... | |
int | ast_dns_resolve_cancel (struct ast_dns_query_active *active) |
Cancel an asynchronous DNS resolution. More... | |
int | ast_dns_resolve_ipv6_and_ipv4 (struct ast_sockaddr *address, const char *host, const char *port) |
Synchronously resolves host to an AAAA or A record. More... | |
void | ast_dns_result_free (struct ast_dns_result *result) |
Free the DNS result information. More... | |
const char * | ast_dns_result_get_answer (const struct ast_dns_result *result) |
Get the raw DNS answer from a DNS result. More... | |
unsigned int | ast_dns_result_get_bogus (const struct ast_dns_result *result) |
Get whether the result is bogus or not. More... | |
const char * | ast_dns_result_get_canonical (const struct ast_dns_result *result) |
Get the canonical name of the result. More... | |
int | ast_dns_result_get_lowest_ttl (const struct ast_dns_result *result) |
Retrieve the lowest TTL from a result. More... | |
unsigned int | ast_dns_result_get_rcode (const struct ast_dns_result *result) |
Get the error rcode of a DN result. More... | |
const struct ast_dns_record * | ast_dns_result_get_records (const struct ast_dns_result *result) |
Get the first record of a DNS Result. More... | |
unsigned int | ast_dns_result_get_secure (const struct ast_dns_result *result) |
Get whether the result is secure or not. More... | |
Core DNS API.
Definition in file dns_core.h.
typedef void(* ast_dns_resolve_callback) (const struct ast_dns_query *query) |
Callback invoked when a query completes.
query | The DNS query that was invoked |
Definition at line 171 of file dns_core.h.
void * ast_dns_query_get_data | ( | const struct ast_dns_query * | query | ) |
Get the user specific data of a DNS query.
query | The DNS query |
Definition at line 72 of file dns_core.c.
References ast_dns_query::user_data.
Referenced by async_callback(), dns_query_recurring_resolution_callback(), dns_query_set_callback(), dns_synchronous_resolve_callback(), query_set_cancel(), query_set_resolve(), recurring_cancel(), recurring_resolve(), and resolution_thread().
const char * ast_dns_query_get_name | ( | const struct ast_dns_query * | query | ) |
Get the name queried in a DNS query.
query | The DNS query |
Definition at line 57 of file dns_core.c.
References ast_dns_query::name.
Referenced by dns_system_resolver_process_query(), dns_system_resolver_resolve(), dns_system_resolver_set_response(), query_set_test(), unbound_resolver_callback(), and unbound_resolver_resolve().
struct ast_dns_result * ast_dns_query_get_result | ( | const struct ast_dns_query * | query | ) |
Get the result information for a DNS query.
query | The DNS query |
Definition at line 77 of file dns_core.c.
References ast_dns_query::result.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), AST_TEST_DEFINE(), dns_query_recurring_resolution_callback(), dns_system_resolver_set_response(), and test_results().
int ast_dns_query_get_rr_class | ( | const struct ast_dns_query * | query | ) |
Get the record resource class of a DNS query.
query | The DNS query |
Definition at line 67 of file dns_core.c.
References ast_dns_query::rr_class.
Referenced by dns_system_resolver_add_record(), dns_system_resolver_process_query(), query_set_test(), and unbound_resolver_resolve().
int ast_dns_query_get_rr_type | ( | const struct ast_dns_query * | query | ) |
Get the record resource type of a DNS query.
query | The DNS query |
Definition at line 62 of file dns_core.c.
References ast_dns_query::rr_type.
Referenced by ast_dns_resolver_completed(), dns_system_resolver_add_record(), dns_system_resolver_process_query(), query_set_test(), and unbound_resolver_resolve().
const char * ast_dns_record_get_data | ( | const struct ast_dns_record * | record | ) |
Retrieve the raw DNS record.
record | The DNS record |
Definition at line 160 of file dns_core.c.
References ast_dns_record::data_ptr.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), ast_dns_txt_get_strings(), and test_record().
size_t ast_dns_record_get_data_size | ( | const struct ast_dns_record * | record | ) |
Retrieve the size of the raw DNS record.
record | The DNS record |
Definition at line 165 of file dns_core.c.
References ast_dns_record::data_len.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), and ast_dns_txt_get_strings().
const struct ast_dns_record * ast_dns_record_get_next | ( | const struct ast_dns_record * | record | ) |
Get the next DNS record.
record | The current DNS record |
Definition at line 170 of file dns_core.c.
References AST_LIST_NEXT, and ast_dns_record::list.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), ast_dns_result_get_lowest_ttl(), AST_TEST_DEFINE(), and nominal_test().
int ast_dns_record_get_rr_class | ( | const struct ast_dns_record * | record | ) |
Get the resource record class of a DNS record.
record | The DNS record |
Definition at line 150 of file dns_core.c.
References ast_dns_record::rr_class.
Referenced by test_record().
int ast_dns_record_get_rr_type | ( | const struct ast_dns_record * | record | ) |
Get the resource record type of a DNS record.
record | The DNS record |
Definition at line 145 of file dns_core.c.
References ast_dns_record::rr_type.
Referenced by 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_resolve_ipv6_and_ipv4(), ast_dns_srv_get_host(), ast_dns_srv_get_port(), ast_dns_srv_get_priority(), ast_dns_srv_get_weight(), ast_dns_txt_get_count(), ast_dns_txt_get_strings(), AST_TEST_DEFINE(), and test_record().
int ast_dns_record_get_ttl | ( | const struct ast_dns_record * | record | ) |
Get the TTL of a DNS record.
record | The DNS record |
Definition at line 155 of file dns_core.c.
References ast_dns_record::ttl.
Referenced by ast_dns_result_get_lowest_ttl(), and test_record().
int ast_dns_resolve | ( | const char * | name, |
int | rr_type, | ||
int | rr_class, | ||
struct ast_dns_result ** | result | ||
) |
Synchronously resolve a DNS query.
name | The name of what to resolve |
rr_type | Resource record type |
rr_class | Resource record class |
result | A pointer to hold the DNS result |
0 | success - query was completed and result is available |
-1 | failure |
Definition at line 314 of file dns_core.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_cond_init, ast_cond_wait, ast_dns_resolve_async(), ast_log, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), dns_synchronous_resolve::completed, dns_synchronous_resolve::cond, dns_synchronous_resolve_callback(), dns_synchronous_resolve_destroy(), dns_synchronous_resolve::lock, LOG_WARNING, name, NULL, result, and dns_synchronous_resolve::result.
Referenced by AST_TEST_DEFINE(), invalid_record_test(), nominal_test(), and off_nominal_test().
struct ast_dns_query_active * ast_dns_resolve_async | ( | const char * | name, |
int | rr_type, | ||
int | rr_class, | ||
ast_dns_resolve_callback | callback, | ||
void * | data | ||
) |
Asynchronously resolve a DNS query.
name | The name of what to resolve |
rr_type | Resource record type |
rr_class | Resource record class |
callback | The callback to invoke upon completion |
data | User data to make available on the query |
non-NULL | success - query has been sent for resolution |
NULL | failure |
Definition at line 247 of file dns_core.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_log, dns_query_active_destroy(), dns_query_alloc(), LOG_ERROR, name, ast_dns_resolver::name, NULL, ast_dns_query_active::query, ast_dns_resolver::resolve, and ast_dns_query::resolver.
Referenced by ast_dns_resolve(), ast_dns_resolve_recurring(), AST_TEST_DEFINE(), and dns_query_recurring_scheduled_callback().
int ast_dns_resolve_cancel | ( | struct ast_dns_query_active * | active | ) |
Cancel an asynchronous DNS resolution.
active | The active DNS query returned from ast_dns_resolve_async |
0 | success |
-1 | failure |
Definition at line 272 of file dns_core.c.
References ast_dns_resolver::cancel, ast_dns_query_active::query, and ast_dns_query::resolver.
Referenced by ast_dns_resolve_recurring_cancel(), and AST_TEST_DEFINE().
int ast_dns_resolve_ipv6_and_ipv4 | ( | struct ast_sockaddr * | address, |
const char * | host, | ||
const char * | port | ||
) |
Synchronously resolves host to an AAAA or A record.
address | A pointer to an ast_sockaddr structure to receive the IPv6 or IPv4 address |
host | The hostname to resolve |
port | (optional) A port to parse into the final ast_sockaddr structure |
0 | success - query was completed and result is available |
-1 | failure |
Definition at line 369 of file dns_core.c.
References ao2_cleanup, ast_debug, ast_dns_query_get_result(), ast_dns_query_set_add(), ast_dns_query_set_create(), ast_dns_query_set_get(), ast_dns_query_set_num_queries(), ast_dns_record_get_data(), ast_dns_record_get_data_size(), ast_dns_record_get_next(), ast_dns_record_get_rr_type(), ast_dns_result_get_records(), ast_log, ast_query_set_resolve(), ast_strlen_zero(), ast_dns_record::data, LOG_ERROR, RAII_VAR, result, and ast_dns_record::rr_type.
Referenced by unicast_rtp_request().
void ast_dns_result_free | ( | struct ast_dns_result * | result | ) |
Free the DNS result information.
result | The DNS result |
Definition at line 130 of file dns_core.c.
References ast_free, AST_LIST_REMOVE_HEAD, ast_dns_record::list, and result.
Referenced by ast_dns_resolver_set_result(), AST_TEST_DEFINE(), dns_query_destroy(), invalid_record_test(), nominal_test(), and off_nominal_test().
const char * ast_dns_result_get_answer | ( | const struct ast_dns_result * | result | ) |
Get the raw DNS answer from a DNS result.
result | The DNS result |
Definition at line 107 of file dns_core.c.
References result.
Referenced by test_results().
unsigned int ast_dns_result_get_bogus | ( | const struct ast_dns_result * | result | ) |
Get whether the result is bogus or not.
result | The DNS result |
Definition at line 87 of file dns_core.c.
References result.
Referenced by test_results().
const char * ast_dns_result_get_canonical | ( | const struct ast_dns_result * | result | ) |
Get the canonical name of the result.
result | The DNS result |
Definition at line 97 of file dns_core.c.
References result.
Referenced by test_results().
int ast_dns_result_get_lowest_ttl | ( | const struct ast_dns_result * | result | ) |
Retrieve the lowest TTL from a result.
result | The DNS result |
Definition at line 112 of file dns_core.c.
References ast_dns_record_get_next(), ast_dns_record_get_ttl(), ast_dns_result_get_rcode(), ast_dns_result_get_records(), result, and ast_dns_record::ttl.
Referenced by dns_query_recurring_resolution_callback().
unsigned int ast_dns_result_get_rcode | ( | const struct ast_dns_result * | result | ) |
Get the error rcode of a DN result.
result | The DNS result |
Definition at line 92 of file dns_core.c.
References result.
Referenced by ast_dns_result_get_lowest_ttl(), and test_results().
const struct ast_dns_record * ast_dns_result_get_records | ( | const struct ast_dns_result * | result | ) |
Get the first record of a DNS Result.
result | The DNS result |
Definition at line 102 of file dns_core.c.
References AST_LIST_FIRST, and result.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), ast_dns_result_get_lowest_ttl(), AST_TEST_DEFINE(), invalid_record_test(), nominal_test(), and off_nominal_test().
unsigned int ast_dns_result_get_secure | ( | const struct ast_dns_result * | result | ) |
Get whether the result is secure or not.
result | The DNS result |
Definition at line 82 of file dns_core.c.
References result.
Referenced by test_results().