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). |
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).
Definition at line 247 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().
00250 { 00251 #ifdef HAVE_RES_NINIT 00252 struct __res_state dnsstate; 00253 #endif 00254 unsigned char answer[MAX_SIZE]; 00255 int res, ret = -1; 00256 00257 #ifdef HAVE_RES_NINIT 00258 res_ninit(&dnsstate); 00259 res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer)); 00260 #else 00261 ast_mutex_lock(&res_lock); 00262 res_init(); 00263 res = res_search(dname, class, type, answer, sizeof(answer)); 00264 #endif 00265 if (res > 0) { 00266 if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { 00267 ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname); 00268 ret = -1; 00269 } 00270 else if (ret == 0) { 00271 ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); 00272 ret = 0; 00273 } 00274 else 00275 ret = 1; 00276 } 00277 #ifdef HAVE_RES_NINIT 00278 #ifdef HAVE_RES_NDESTROY 00279 res_ndestroy(&dnsstate); 00280 #else 00281 res_nclose(&dnsstate); 00282 #endif 00283 #else 00284 #ifndef __APPLE__ 00285 res_close(); 00286 #endif 00287 ast_mutex_unlock(&res_lock); 00288 #endif 00289 00290 return ret; 00291 }