Mon May 14 04:48:23 2007

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

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 188 of file dns.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dns_parse_answer(), LOG_DEBUG, LOG_WARNING, and MAX_SIZE.

Referenced by ast_get_enum(), ast_get_srv(), and ast_get_txt().

00191 {
00192 #if HAVE_RES_NINIT
00193    struct __res_state dnsstate;
00194 #endif
00195    unsigned char answer[MAX_SIZE];
00196    int res, ret = -1;
00197 
00198 #if HAVE_RES_NINIT
00199    res_ninit(&dnsstate);
00200    res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
00201 #else
00202    ast_mutex_lock(&res_lock);
00203    res_init();
00204    res = res_search(dname, class, type, answer, sizeof(answer));
00205 #endif
00206    if (res > 0) {
00207       if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) {
00208          ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname);
00209          ret = -1;
00210       }
00211       else if (ret == 0) {
00212          ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname);
00213          ret = 0;
00214       }
00215       else
00216          ret = 1;
00217    }
00218 #if HAVE_RES_NINIT
00219    res_nclose(&dnsstate);
00220 #else
00221 #ifndef __APPLE__
00222    res_close();
00223 #endif
00224    ast_mutex_unlock(&res_lock);
00225 #endif
00226 
00227    return ret;
00228 }


Generated on Mon May 14 04:48:23 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1