Wed Mar 3 22:54:01 2010

Asterisk developer's documentation


dns.h File Reference

DNS support for Asterisk. More...

This graph shows which files directly or indirectly include this file:

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).

Detailed Description

DNS support for Asterisk.

Author:
Thorsten Lockert <tholo@trollphone.org>

Definition in file dns.h.


Function Documentation

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 255 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(), blr_ebl(), and blr_txt().

00258 {
00259 #ifdef HAVE_RES_NINIT
00260    struct __res_state dnsstate;
00261 #endif
00262    unsigned char answer[MAX_SIZE];
00263    int res, ret = -1;
00264 
00265 #ifdef HAVE_RES_NINIT
00266    memset(&dnsstate, 0, sizeof(dnsstate));
00267    res_ninit(&dnsstate);
00268    res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
00269 #else
00270    ast_mutex_lock(&res_lock);
00271    res_init();
00272    res = res_search(dname, class, type, answer, sizeof(answer));
00273 #endif
00274    if (res > 0) {
00275       if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) {
00276          ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname);
00277          ret = -1;
00278       } else if (res == 0) {
00279          ast_debug(1, "No matches found in DNS for %s\n", dname);
00280          ret = 0;
00281       } else
00282          ret = 1;
00283    }
00284 #ifdef HAVE_RES_NINIT
00285 #ifdef HAVE_RES_NDESTROY
00286    res_ndestroy(&dnsstate);
00287 #else
00288    res_nclose(&dnsstate);
00289 #endif
00290 #else
00291 #ifndef __APPLE__
00292    res_close();
00293 #endif
00294    ast_mutex_unlock(&res_lock);
00295 #endif
00296 
00297    return ret;
00298 }


Generated on 3 Mar 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1