![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
dns.h File Reference
Definition in file dns.h.
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). | |
|
||||||||||||||||||||||||
|
Perform DNS lookup (used by DNS, enum and SRV lookups).
Definition at line 189 of file dns.c. References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dns_parse_answer(), LOG_DEBUG, LOG_WARNING, MAX_SIZE, and option_debug. Referenced by ast_get_enum(), and ast_get_srv(). 00192 { 00193 #if HAVE_RES_NINIT 00194 struct __res_state dnsstate; 00195 #endif 00196 unsigned char answer[MAX_SIZE]; 00197 int res, ret = -1; 00198 00199 #if HAVE_RES_NINIT 00200 res_ninit(&dnsstate); 00201 res = res_nsearch(&dnsstate, dname, class, type, 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 if (option_debug) 00214 ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); 00215 ret = 0; 00216 } 00217 else 00218 ret = 1; 00219 } 00220 #if HAVE_RES_NINIT 00221 res_nclose(&dnsstate); 00222 #else 00223 #ifndef __APPLE__ 00224 res_close(); 00225 #endif 00226 ast_mutex_unlock(&res_lock); 00227 #endif 00228 00229 return ret; 00230 }
|