Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

dns.c File Reference

#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>

Go to the source code of this file.

Data Structures

struct  dns_HEADER
struct  dn_answer

Defines

#define MAX_SIZE   4096

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))

Variables

dn_answer __packed__


Define Documentation

#define MAX_SIZE   4096
 

Definition at line 23 of file dns.c.

Referenced by ast_search_dns().


Function Documentation

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 }


Variable Documentation

struct dn_answer __packed__
 


Generated on Sun Apr 18 23:34:03 2004 for Asterisk by doxygen 1.3.6-20040222