Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

dns.h File Reference

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

Included by dependency graph

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, u_char *answer, int len, u_char *fullanswer))


Function Documentation

int ast_search_dns void *  context,
const char *  dname,
int  class,
int  type,
int(*  callback)(void *context, u_char *answer, int len, u_char *fullanswer)
 

Definition at line 163 of file dns.c.

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

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

00166 { 00167 #ifdef HAS_RES_NINIT 00168 struct __res_state dnsstate; 00169 #endif 00170 char answer[MAX_SIZE]; 00171 int res, ret = -1; 00172 00173 #ifdef HAS_RES_NINIT 00174 res_ninit(&dnsstate); 00175 res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer)); 00176 #else 00177 ast_mutex_lock(&res_lock); 00178 res_init(); 00179 res = res_search(dname, class, type, answer, sizeof(answer)); 00180 #endif 00181 if (res > 0) { 00182 if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { 00183 ast_log(LOG_WARNING, "Parse error\n"); 00184 ret = -1; 00185 } 00186 else if (ret == 0) { 00187 ast_log(LOG_DEBUG, "No matches found\n"); 00188 ret = 0; 00189 } 00190 else 00191 ret = 1; 00192 } 00193 #ifdef HAS_RES_NINIT 00194 res_nclose(&dnsstate); 00195 #else 00196 #ifndef __APPLE__ 00197 res_close(); 00198 #endif 00199 ast_mutex_unlock(&res_lock); 00200 #endif 00201 return ret; 00202 }


Generated on Sat Jun 12 16:41:31 2004 for Asterisk by doxygen 1.3.7