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)) |
|
Definition at line 154 of file dns.c. References ast_log(), LOG_DEBUG, LOG_WARNING, and MAX_SIZE. Referenced by ast_get_enum(), and ast_get_srv().
00157 { 00158 #ifdef linux 00159 struct __res_state dnsstate; 00160 #endif 00161 char answer[MAX_SIZE]; 00162 int res, ret = -1; 00163 00164 #ifdef linux 00165 res_ninit(&dnsstate); 00166 res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer)); 00167 #else 00168 res_init(); 00169 res = res_search(dname, class, type, answer, sizeof(answer)); 00170 #endif 00171 if (res > 0) { 00172 if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { 00173 ast_log(LOG_WARNING, "Parse error\n"); 00174 ret = -1; 00175 } 00176 else if (ret == 0) { 00177 ast_log(LOG_DEBUG, "No matches found\n"); 00178 ret = 0; 00179 } 00180 else 00181 ret = 1; 00182 } 00183 #if defined(linux) 00184 res_nclose(&dnsstate); 00185 #else 00186 #ifndef __APPLE__ 00187 res_close(); 00188 #endif 00189 #endif 00190 return ret; 00191 } |