DNS support for Asterisk.
More...
Go to the source code of this file.
|
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) More...
|
|
DNS support for Asterisk.
- Author
- Thorsten Lockert tholo.nosp@m.@tro.nosp@m.llpho.nosp@m.ne.o.nosp@m.rg
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)
- Parameters
-
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 |
- Note
- Asterisk DNS is synchronus at this time. This means that if your DNS services does not work, Asterisk may lock while waiting for response.
Perform DNS lookup (used by DNS, enum and SRV lookups)
- Note
- Asterisk DNS is synchronus at this time. This means that if your DNS does not work properly, Asterisk might not start properly or a channel may lock.
Definition at line 259 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_srv_lookup(), blr_ebl(), and blr_txt().
263 #ifdef HAVE_RES_NINIT
264 struct __res_state dnsstate;
269 #ifdef HAVE_RES_NINIT
270 memset(&dnsstate, 0,
sizeof(dnsstate));
271 res_ninit(&dnsstate);
272 res = res_nsearch(&dnsstate, dname,
class,
type, answer,
sizeof(answer));
276 res = res_search(dname,
class,
type, answer,
sizeof(answer));
282 }
else if (res == 0) {
283 ast_debug(1,
"No matches found in DNS for %s\n", dname);
288 #ifdef HAVE_RES_NINIT
289 #ifdef HAVE_RES_NDESTROY
290 res_ndestroy(&dnsstate);
292 res_nclose(&dnsstate);
295 #ifdef HAVE_RES_CLOSE
#define ast_mutex_lock(a)
#define ast_debug(level,...)
Log a DEBUG message.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static char context[AST_MAX_CONTEXT]
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.
#define ast_mutex_unlock(a)