DNS support for Asterisk. More...
Go to the source code of this file.
Functions | |
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)) |
Perform DNS lookup (used by DNS, enum and SRV lookups) |
DNS support for Asterisk.
Definition in file dns.h.
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 | ||
) |
Perform DNS lookup (used by DNS, enum and SRV lookups)
context | |
dname | Domain name to lookup (host, SRV domain, TXT record name) |
class | Record Class (see "man res_search") |
type | Record type (see "man res_search") |
callback | Callback function for handling DNS result |
Perform DNS lookup (used by DNS, enum and SRV lookups)
Definition at line 255 of file dns.c.
References ast_debug, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dns_parse_answer(), LOG_WARNING, MAX_SIZE, and res_lock.
Referenced by ast_get_enum(), ast_get_srv(), blr_ebl(), and blr_txt().
{ #ifdef HAVE_RES_NINIT struct __res_state dnsstate; #endif unsigned char answer[MAX_SIZE]; int res, ret = -1; #ifdef HAVE_RES_NINIT memset(&dnsstate, 0, sizeof(dnsstate)); res_ninit(&dnsstate); res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer)); #else ast_mutex_lock(&res_lock); res_init(); res = res_search(dname, class, type, answer, sizeof(answer)); #endif if (res > 0) { if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname); ret = -1; } else if (res == 0) { ast_debug(1, "No matches found in DNS for %s\n", dname); ret = 0; } else ret = 1; } #ifdef HAVE_RES_NINIT #ifdef HAVE_RES_NDESTROY res_ndestroy(&dnsstate); #else res_nclose(&dnsstate); #endif #else #ifndef __APPLE__ res_close(); #endif ast_mutex_unlock(&res_lock); #endif return ret; }