#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/nameser.h>#include <resolv.h>#include <unistd.h>#include <asterisk/logger.h>#include <asterisk/channel.h>#include <asterisk/dns.h>#include "asterisk/endian.h"

Go to the source code of this file.
Data Structures | |
| struct | dns_HEADER |
| struct | dn_answer |
Defines | |
| #define | MAX_SIZE 4096 |
Functions | |
| AST_MUTEX_DEFINE_STATIC (res_lock) | |
| 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)) |
Variables | |
| struct dn_answer | __packed__ |
| AST_MUTEX_DEFINE_STATIC | ( | res_lock | ) |
| int ast_search_dns | ( | void * | context, | |
| const char * | dname, | |||
| int | class, | |||
| int | type, | |||
| int(*)(void *context, u_char *answer, int len, u_char *fullanswer) | callback | |||
| ) |
Definition at line 164 of file dns.c.
00167 { 00168 #ifdef HAS_RES_NINIT 00169 struct __res_state dnsstate; 00170 #endif 00171 char answer[MAX_SIZE]; 00172 int res, ret = -1; 00173 00174 #ifdef HAS_RES_NINIT 00175 res_ninit(&dnsstate); 00176 res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer)); 00177 #else 00178 ast_mutex_lock(&res_lock); 00179 res_init(); 00180 res = res_search(dname, class, type, answer, sizeof(answer)); 00181 #endif 00182 if (res > 0) { 00183 if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { 00184 ast_log(LOG_WARNING, "Parse error\n"); 00185 ret = -1; 00186 } 00187 else if (ret == 0) { 00188 ast_log(LOG_DEBUG, "No matches found\n"); 00189 ret = 0; 00190 } 00191 else 00192 ret = 1; 00193 } 00194 #ifdef HAS_RES_NINIT 00195 res_nclose(&dnsstate); 00196 #else 00197 #ifndef __APPLE__ 00198 res_close(); 00199 #endif 00200 ast_mutex_unlock(&res_lock); 00201 #endif 00202 return ret; 00203 }
| struct dn_answer __packed__ |
1.5.6