Asterisk - The Open Source Telephony Project
18.5.0
|
Core DNS Functionality. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/linkedlists.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/sched.h"
#include "asterisk/dns_core.h"
#include "asterisk/dns_srv.h"
#include "asterisk/dns_tlsa.h"
#include "asterisk/dns_recurring.h"
#include "asterisk/dns_resolver.h"
#include "asterisk/dns_internal.h"
#include "asterisk/netsock2.h"
#include <netinet/in.h>
#include <arpa/nameser.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... | |
struct | resolvers |
Typedefs | |
typedef struct ast_dns_record *(* | dns_alloc_fn) (struct ast_dns_query *query, const char *data, const size_t size) |
typedef void(* | dns_sort_fn) (struct ast_dns_result *result) |
Functions | |
static struct ast_dns_record * | allocate_dns_record (unsigned int rr_type, struct ast_dns_query *query, const char *data, const size_t size) |
struct ast_sched_context * | ast_dns_get_sched (void) |
Retrieve the DNS scheduler context. More... | |
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... | |
int | ast_dns_resolver_add_record (struct ast_dns_query *query, int rr_type, int rr_class, int ttl, const char *data, const size_t size) |
Add a DNS record to the result of a DNS query. More... | |
void | ast_dns_resolver_completed (struct ast_dns_query *query) |
Mark a DNS query as having been completed. More... | |
void * | ast_dns_resolver_get_data (const struct ast_dns_query *query) |
Retrieve resolver specific data. More... | |
int | ast_dns_resolver_register (struct ast_dns_resolver *resolver) |
Register a DNS resolver. More... | |
int | ast_dns_resolver_set_data (struct ast_dns_query *query, void *data) |
Set resolver specific data on a query. More... | |
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. More... | |
void | ast_dns_resolver_unregister (struct ast_dns_resolver *resolver) |
Unregister a DNS resolver. 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... | |
int | dns_core_init (void) |
char * | dns_find_record (const char *record, size_t record_size, const char *response, size_t response_size) |
Find the location of a DNS record within the entire DNS answer. More... | |
int | dns_parse_short (unsigned char *cur, uint16_t *val) |
Parse a 16-bit unsigned value from a DNS record. More... | |
int | dns_parse_string (char *cur, uint8_t *size, char **val) |
Parse a DNS string from a DNS record. More... | |
static void | dns_query_active_destroy (void *data) |
Destructor for an active DNS query. More... | |
struct ast_dns_query * | dns_query_alloc (const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data) |
Allocate a DNS query (but do not start resolution) More... | |
static void | dns_query_destroy (void *data) |
Destructor for a DNS query. More... | |
static void | dns_shutdown (void) |
static void | dns_synchronous_resolve_callback (const struct ast_dns_query *query) |
Callback used to implement synchronous resolution. More... | |
static void | dns_synchronous_resolve_destroy (void *data) |
Destructor for synchronous resolution structure. More... | |
static struct ast_dns_record * | generic_record_alloc (struct ast_dns_query *query, const char *data, const size_t size) |
static void | sort_result (int rr_type, struct ast_dns_result *result) |
Variables | |
static dns_alloc_fn | dns_alloc_table [] |
static dns_sort_fn | dns_sort_table [] |
struct resolvers | resolvers = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static struct ast_sched_context * | sched |
Core DNS Functionality.
Definition in file dns_core.c.
typedef struct ast_dns_record*(* dns_alloc_fn) (struct ast_dns_query *query, const char *data, const size_t size) |
Definition at line 516 of file dns_core.c.
typedef void(* dns_sort_fn) (struct ast_dns_result *result) |
Definition at line 585 of file dns_core.c.
|
static |
Definition at line 524 of file dns_core.c.
References ARRAY_LEN, dns_alloc_table, generic_record_alloc(), and ast_dns_record::rr_type.
Referenced by ast_dns_resolver_add_record().
struct ast_sched_context* ast_dns_get_sched | ( | void | ) |
Retrieve the DNS scheduler context.
Definition at line 52 of file dns_core.c.
References sched.
Referenced by ast_dns_resolve_recurring(), ast_dns_resolve_recurring_cancel(), and dns_query_recurring_resolution_callback().
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(), minimal_callback(), off_nominal_async_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(), sip_resolve_callback(), 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(), async_callback(), dns_query_recurring_resolution_callback(), dns_system_resolver_set_response(), off_nominal_async_callback(), sip_resolve_callback(), 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(), sip_resolve_callback(), 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(), async_callback(), nominal_sync_run(), sip_resolve_callback(), 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(), ast_dns_txt_get_strings(), and sip_resolve_callback().
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(), async_callback(), nominal_sync_run(), nominal_test(), and sip_resolve_callback().
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 async_callback(), nominal_sync_run(), and 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(), async_callback(), nominal_sync_run(), sip_resolve_callback(), 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(), async_callback(), nominal_sync_run(), 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, NULL, and dns_synchronous_resolve::result.
Referenced by AST_TEST_DEFINE(), invalid_record_test(), nominal_sync_run(), nominal_test(), off_nominal_sync_run(), 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, 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(), dns_query_recurring_scheduled_callback(), nominal_async_run(), and off_nominal_async_run().
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, ast_sockaddr::len, LOG_ERROR, RAII_VAR, dns_synchronous_resolve::result, ast_dns_record::rr_type, and ast_sockaddr::ss.
Referenced by unicast_rtp_request().
int ast_dns_resolver_add_record | ( | struct ast_dns_query * | query, |
int | rr_type, | ||
int | rr_class, | ||
int | ttl, | ||
const char * | data, | ||
const size_t | size | ||
) |
Add a DNS record to the result of a DNS query.
query | The DNS query |
rr_type | Resource record type |
rr_class | Resource record class |
ttl | TTL of the record |
data | The raw DNS record |
size | The size of the raw DNS record |
0 | success |
-1 | failure |
Definition at line 535 of file dns_core.c.
References allocate_dns_record(), ast_debug, AST_LIST_INSERT_TAIL, ast_dns_record::data_len, ast_dns_record::data_ptr, ast_dns_record::list, ast_dns_result::records, ast_dns_query::result, ast_dns_record::rr_class, ast_dns_record::rr_type, and ast_dns_record::ttl.
Referenced by AST_TEST_DEFINE(), dns_system_resolver_add_record(), naptr_thread(), resolution_thread(), srv_thread(), and unbound_resolver_callback().
void ast_dns_resolver_completed | ( | struct ast_dns_query * | query | ) |
Mark a DNS query as having been completed.
query | The DNS query |
Definition at line 599 of file dns_core.c.
References ast_dns_query_get_rr_type(), ast_dns_query::callback, ast_dns_query::result, and sort_result().
Referenced by dns_system_resolver_process_query(), naptr_thread(), resolution_thread(), srv_thread(), and unbound_resolver_callback().
void* ast_dns_resolver_get_data | ( | const struct ast_dns_query * | query | ) |
Retrieve resolver specific data.
query | The DNS query |
Definition at line 451 of file dns_core.c.
References ast_dns_query::resolver_data.
Referenced by AST_TEST_DEFINE(), and unbound_resolver_cancel().
int ast_dns_resolver_register | ( | struct ast_dns_resolver * | resolver | ) |
Register a DNS resolver.
resolver | A DNS resolver implementation |
0 | success |
-1 | failure |
Definition at line 630 of file dns_core.c.
References AST_LIST_TRAVERSE, ast_log, AST_RWLIST_INSERT_BEFORE_CURRENT, AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero, ast_verb, ast_dns_resolver::cancel, LOG_ERROR, ast_dns_resolver::name, ast_dns_resolver::priority, and ast_dns_resolver::resolve.
Referenced by ast_dns_system_resolver_init(), AST_TEST_DEFINE(), invalid_record_test(), load_module(), nominal_test(), off_nominal_test(), and query_set_test().
int ast_dns_resolver_set_data | ( | struct ast_dns_query * | query, |
void * | data | ||
) |
Set resolver specific data on a query.
query | The DNS query |
data | The resolver specific data |
0 | success |
-1 | failure, resolver data is already set |
Definition at line 440 of file dns_core.c.
References ao2_bump, and ast_dns_query::resolver_data.
Referenced by AST_TEST_DEFINE(), and unbound_resolver_resolve().
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.
query | The DNS query |
result | Whether the result is secured or not |
bogus | Whether the result is bogus or not |
rcode | Optional response code |
canonical | The canonical name |
answer | The raw DNS answer |
answer_size | The size of the raw DNS answer |
Zero-sized and NULL answers are permitted by this function. This may be necessary if the query fails at an early stage and no actual DNS response has been received from a DNS server.
0 | success |
-1 | failure |
Definition at line 456 of file dns_core.c.
References ast_dns_result::answer, ast_dns_result::answer_size, ast_calloc, ast_debug, ast_dns_result_free(), ast_strlen_zero, ast_dns_result::bogus, ast_dns_result::buf, ast_dns_result::canonical, ast_dns_result::rcode, ast_dns_query::result, and ast_dns_result::secure.
Referenced by AST_TEST_DEFINE(), dns_system_resolver_set_response(), naptr_thread(), resolution_thread(), srv_thread(), and unbound_resolver_callback().
void ast_dns_resolver_unregister | ( | struct ast_dns_resolver * | resolver | ) |
Unregister a DNS resolver.
resolver | A DNS resolver implementation |
Definition at line 680 of file dns_core.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, and ast_dns_resolver::name.
Referenced by AST_TEST_DEFINE(), dns_system_resolver_destroy(), invalid_record_test(), nominal_test(), off_nominal_test(), and query_set_test().
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 ast_dns_result::records.
Referenced by ast_dns_resolver_set_result(), AST_TEST_DEFINE(), dns_query_destroy(), invalid_record_test(), nominal_sync_run(), nominal_test(), off_nominal_sync_run(), 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 ast_dns_result::answer.
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 ast_dns_result::bogus.
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 ast_dns_result::canonical.
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(), 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.
query | The DNS result |
Definition at line 92 of file dns_core.c.
References ast_dns_result::rcode.
Referenced by ast_dns_result_get_lowest_ttl(), off_nominal_async_callback(), off_nominal_sync_run(), 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 ast_dns_result::records.
Referenced by ast_dns_resolve_ipv6_and_ipv4(), ast_dns_result_get_lowest_ttl(), AST_TEST_DEFINE(), async_callback(), invalid_record_test(), nominal_sync_run(), nominal_test(), off_nominal_async_callback(), off_nominal_sync_run(), off_nominal_test(), and sip_resolve_callback().
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 ast_dns_result::secure.
Referenced by test_results().
int dns_core_init | ( | void | ) |
Provided by dns_core.c
Definition at line 614 of file dns_core.c.
References ast_register_cleanup(), ast_sched_context_create(), ast_sched_start_thread(), and dns_shutdown().
Referenced by asterisk_daemon().
char* dns_find_record | ( | const char * | record, |
size_t | record_size, | ||
const char * | response, | ||
size_t | response_size | ||
) |
Find the location of a DNS record within the entire DNS answer.
The DNS record that has been returned by the resolver may be a copy of the record that was found in the complete DNS response. If so, then some DNS record types (specifically those that parse domains) will need to locate the DNS record within the complete DNS response. This is so that if the domain contains pointers to other sections of the DNS response, then the referenced domains may be located.
record | The DNS record returned by a resolver implementation |
record_size | The size of the DNS record in bytes |
response | The complete DNS answer |
response_size | The size of the complete DNS response |
Definition at line 701 of file dns_core.c.
References ast_assert, and NULL.
Referenced by dns_naptr_alloc(), and dns_srv_alloc().
int dns_parse_short | ( | unsigned char * | cur, |
uint16_t * | val | ||
) |
Parse a 16-bit unsigned value from a DNS record.
cur | Pointer to the location of the 16-bit value in the DNS record | |
[out] | val | The parsed 16-bit unsigned integer |
Definition at line 722 of file dns_core.c.
Referenced by dns_naptr_alloc(), and dns_srv_alloc().
int dns_parse_string | ( | char * | cur, |
uint8_t * | size, | ||
char ** | val | ||
) |
Parse a DNS string from a DNS record.
A DNS string consists of an 8-bit size, followed by the string value (not NULL-terminated).
cur | Pointer to the location of the DNS string | |
[out] | size | The parsed size of the DNS string |
[out] | val | The contained string (not NULL-terminated) |
Definition at line 734 of file dns_core.c.
Referenced by dns_naptr_alloc().
|
static |
Destructor for an active DNS query.
Definition at line 176 of file dns_core.c.
References ao2_cleanup, and ast_dns_query_active::query.
Referenced by ast_dns_resolve_async().
struct ast_dns_query* dns_query_alloc | ( | const char * | name, |
int | rr_type, | ||
int | rr_class, | ||
ast_dns_resolve_callback | callback, | ||
void * | data | ||
) |
Allocate a DNS query (but do not start resolution)
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 |
NULL | failure |
Definition at line 193 of file dns_core.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ao2_ref, ast_log, AST_RWLIST_FIRST, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strlen_zero, ast_dns_query::callback, dns_query_destroy(), LOG_ERROR, LOG_WARNING, ast_dns_query::name, NULL, ast_dns_query::resolver, ast_dns_query::rr_class, ast_dns_query::rr_type, and ast_dns_query::user_data.
Referenced by ast_dns_query_set_add(), ast_dns_resolve_async(), and dns_query_recurring_resolution_callback().
|
static |
Destructor for a DNS query.
Definition at line 184 of file dns_core.c.
References ao2_cleanup, ast_dns_result_free(), ast_dns_query::resolver_data, ast_dns_query::result, and ast_dns_query::user_data.
Referenced by dns_query_alloc().
|
static |
Definition at line 606 of file dns_core.c.
References ast_sched_context_destroy(), and NULL.
Referenced by dns_core_init().
|
static |
Callback used to implement synchronous resolution.
Definition at line 301 of file dns_core.c.
References ast_cond_signal, ast_dns_query_get_data(), ast_mutex_lock, ast_mutex_unlock, dns_synchronous_resolve::completed, dns_synchronous_resolve::cond, dns_synchronous_resolve::lock, NULL, ast_dns_query::result, and dns_synchronous_resolve::result.
Referenced by ast_dns_resolve().
|
static |
Destructor for synchronous resolution structure.
Definition at line 290 of file dns_core.c.
References ast_cond_destroy, ast_mutex_destroy, dns_synchronous_resolve::cond, and dns_synchronous_resolve::lock.
Referenced by ast_dns_resolve().
|
static |
Definition at line 502 of file dns_core.c.
References ast_calloc, ast_dns_record::data, ast_dns_record::data_ptr, and NULL.
Referenced by allocate_dns_record().
|
static |
Definition at line 592 of file dns_core.c.
References dns_sort_table, and dns_synchronous_resolve::result.
Referenced by ast_dns_resolver_completed().
|
static |
Definition at line 518 of file dns_core.c.
Referenced by allocate_dns_record().
|
static |
Definition at line 587 of file dns_core.c.
Referenced by sort_result().
struct resolvers resolvers = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
|
static |
Definition at line 50 of file dns_core.c.
Referenced by ast_dns_get_sched().