Asterisk - The Open Source Telephony Project
18.5.0
|
DNS Support for Asterisk. More...
#include "asterisk.h"
#include "asterisk/network.h"
#include <arpa/nameser.h>
#include <resolv.h>
#include "asterisk/channel.h"
#include "asterisk/dns.h"
#include "asterisk/endian.h"
Go to the source code of this file.
Data Structures | |
struct | dn_answer |
struct | dns_HEADER |
Macros | |
#define | MAX_SIZE 4096 |
The maximum size permitted for the answer from the DNS server. More... | |
Functions | |
struct ao2_container * | ast_dns_get_nameservers (void) |
Retrieve the configured nameservers of the system. More... | |
int | ast_search_dns (void *context, const char *dname, int class, int type, int(*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer)) |
Lookup record in DNS. More... | |
enum ast_dns_search_result | ast_search_dns_ex (void *context, const char *dname, int rr_class, int rr_type, int(*response_handler)(void *context, unsigned char *dns_response, int dns_response_len, int rcode), int(*record_handler)(void *context, unsigned char *record, int record_len, int ttl)) |
Extended version of the DNS search function. More... | |
static int | dns_advance_field (unsigned char **dns_response, int remaining_len, int field_size) |
Advances the position of the DNS response pointer by the size of the current field. More... | |
static int | dns_parse_answer (void *context, int class, int type, unsigned char *answer, int len, int(*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer)) |
Parse DNS lookup result, call callback. More... | |
static int | dns_parse_answer_ex (void *context, int rr_class, int rr_type, unsigned char *answer, int answer_len, int(*response_handler)(void *context, unsigned char *dns_response, int dns_response_len, int rcode), int(*record_handler)(void *context, unsigned char *record, int record_len, int ttl)) |
Extended version of the DNS Parsing function. More... | |
static int | dns_search_res (const char *dname, int rr_class, int rr_type, unsigned char *dns_response, int dns_response_len) |
Handles the DNS search if the system has RES_NINIT. More... | |
static int | skip_name (unsigned char *s, int len) |
Tries to find the position of the next field in the DNS response. More... | |
DNS Support for Asterisk.
Definition in file dns.c.
#define MAX_SIZE 4096 |
The maximum size permitted for the answer from the DNS server.
Definition at line 47 of file dns.c.
Referenced by ast_search_dns(), and ast_search_dns_ex().
struct ao2_container* ast_dns_get_nameservers | ( | void | ) |
Retrieve the configured nameservers of the system.
Definition at line 583 of file dns.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ast_inet_ntoa(), ast_mutex_lock, ast_mutex_unlock, ast_str_container_add(), ast_str_container_alloc_options(), NULL, and state.
Referenced by system_create_resolver_and_set_nameservers().
int ast_search_dns | ( | void * | context, |
const char * | dname, | ||
int | class, | ||
int | type, | ||
int(*)(void *context, unsigned char *answer, int len, unsigned char *fullanswer) | callback | ||
) |
Lookup record in DNS.
Perform DNS lookup (used by DNS, enum and SRV lookups)
Definition at line 493 of file dns.c.
References ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, dns_parse_answer(), LOG_WARNING, and MAX_SIZE.
Referenced by ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_srv_lookup(), blr_ebl(), and blr_txt().
enum ast_dns_search_result ast_search_dns_ex | ( | void * | context, |
const char * | dname, | ||
int | rr_class, | ||
int | rr_type, | ||
int(*)(void *context, unsigned char *dns_response, int dns_response_len, int rcode) | response_handler, | ||
int(*)(void *context, unsigned char *record, int record_len, int ttl) | record_handler | ||
) |
Extended version of the DNS search function.
Performs a DNS lookup, (used by DNS, enum and SRV lookups), parses the results and notifies the observer with the response and discovered records via invoking the provided callbacks (used by ast_dns_system_resolver).
context | Void pointer containing data to use in the handler functions. |
dname | Domain name to lookup (host, SRV domain, TXT record name). |
rr_class | Record Class (see "man res_search"). |
rr_type | Record type (see "man res_search"). |
response_handler | Callback function for handling the DNS response. Invoked upon completion of the DNS search. |
record_handler | Callback function for handling the discovered resource records from the DNS search. Invoked n times, where n is the number of records discovered while parsing the DNS response. |
AST_DNS_SEARCH_FAILURE | on search failure |
AST_DNS_SEARCH_NO_RECORDS | on no records found |
AST_DNS_SEARCH_SUCCESS | on success |
Definition at line 538 of file dns.c.
References ast_assert, ast_debug, AST_DNS_SEARCH_FAILURE, AST_DNS_SEARCH_NO_RECORDS, ast_log, dns_parse_answer_ex(), dns_search_res(), LOG_WARNING, MAX_SIZE, and NULL.
Referenced by dns_system_resolver_process_query().
|
static |
Advances the position of the DNS response pointer by the size of the current field.
Definition at line 223 of file dns.c.
References AST_DNS_SEARCH_FAILURE, ast_mutex_lock, ast_mutex_unlock, dns_search_res(), and NULL.
Referenced by dns_parse_answer_ex().
|
static |
Parse DNS lookup result, call callback.
Definition at line 330 of file dns.c.
References dns_HEADER::ancount, answer(), ast_log, dn_answer::class, LOG_WARNING, dns_HEADER::qdcount, dn_answer::rtype, dn_answer::size, and skip_name().
Referenced by ast_search_dns().
|
static |
Extended version of the DNS Parsing function.
Parses the DNS lookup result and notifies the observer of each discovered resource record with the provided callback.
Definition at line 409 of file dns.c.
References dns_HEADER::ancount, answer(), AST_DNS_SEARCH_FAILURE, AST_DNS_SEARCH_NO_RECORDS, AST_DNS_SEARCH_SUCCESS, ast_log, dn_answer::class, dns_advance_field(), LOG_WARNING, dns_HEADER::qdcount, dn_answer::rtype, dn_answer::size, skip_name(), and dn_answer::ttl.
Referenced by ast_search_dns_ex().
|
static |
Handles the DNS search if the system has RES_NINIT.
Definition at line 287 of file dns.c.
References AST_DNS_SEARCH_FAILURE.
Referenced by ast_search_dns_ex(), and dns_advance_field().
|
static |
Tries to find the position of the next field in the DNS response.
Definition at line 179 of file dns.c.
References AST_DNS_SEARCH_FAILURE.
Referenced by dns_parse_answer(), and dns_parse_answer_ex().