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, char *answer, int len, char *fullanswer)) |
Perform DNS lookup (used by enum and SRV lookups). |
Definition in file dns.h.
|
Perform DNS lookup (used by enum and SRV lookups).
Definition at line 186 of file dns.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dns_parse_answer(), LOG_DEBUG, LOG_WARNING, and type. Referenced by ast_get_enum(), ast_get_srv(), and ast_get_txt(). 00189 { 00190 #ifdef HAS_RES_NINIT 00191 struct __res_state dnsstate; 00192 #endif 00193 char answer[MAX_SIZE]; 00194 int res, ret = -1; 00195 00196 #ifdef HAS_RES_NINIT 00197 #ifdef MAKE_VALGRIND_HAPPY 00198 memset(&dnsstate, 0, sizeof(dnsstate)); 00199 #endif 00200 res_ninit(&dnsstate); 00201 res = res_nsearch(&dnsstate, dname, class, type, (unsigned char *)answer, sizeof(answer)); 00202 #else 00203 ast_mutex_lock(&res_lock); 00204 res_init(); 00205 res = res_search(dname, class, type, answer, sizeof(answer)); 00206 #endif 00207 if (res > 0) { 00208 if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { 00209 ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname); 00210 ret = -1; 00211 } 00212 else if (ret == 0) { 00213 ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); 00214 ret = 0; 00215 } 00216 else 00217 ret = 1; 00218 } 00219 #ifdef HAS_RES_NINIT 00220 res_nclose(&dnsstate); 00221 #else 00222 #ifndef __APPLE__ 00223 res_close(); 00224 #endif 00225 ast_mutex_unlock(&res_lock); 00226 #endif 00227 return ret; 00228 }
|