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