00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ARES__H
00026 #define ARES__H
00027
00028 #define ARES_SUCCESS 0
00029
00030
00031 #define ARES_ENODATA 1
00032 #define ARES_EFORMERR 2
00033 #define ARES_ESERVFAIL 3
00034 #define ARES_ENOTFOUND 4
00035 #define ARES_ENOTIMP 5
00036 #define ARES_EREFUSED 6
00037
00038
00039 #define ARES_EBADQUERY 7
00040 #define ARES_EBADNAME 8
00041 #define ARES_EBADFAMILY 9
00042 #define ARES_EBADRESP 10
00043 #define ARES_ECONNREFUSED 11
00044 #define ARES_ETIMEOUT 12
00045 #define ARES_EOF 13
00046 #define ARES_EFILE 14
00047 #define ARES_ENOMEM 15
00048 #define ARES_EDESTRUCTION 16
00049
00050
00051 #define ARES_FLAG_USEVC (1 << 0)
00052 #define ARES_FLAG_PRIMARY (1 << 1)
00053 #define ARES_FLAG_IGNTC (1 << 2)
00054 #define ARES_FLAG_NORECURSE (1 << 3)
00055 #define ARES_FLAG_STAYOPEN (1 << 4)
00056 #define ARES_FLAG_NOSEARCH (1 << 5)
00057 #define ARES_FLAG_NOALIASES (1 << 6)
00058 #define ARES_FLAG_NOCHECKRESP (1 << 7)
00059
00060
00061 #define ARES_OPT_FLAGS (1 << 0)
00062 #define ARES_OPT_TIMEOUT (1 << 1)
00063 #define ARES_OPT_TRIES (1 << 2)
00064 #define ARES_OPT_NDOTS (1 << 3)
00065 #define ARES_OPT_UDP_PORT (1 << 4)
00066 #define ARES_OPT_TCP_PORT (1 << 5)
00067 #define ARES_OPT_SERVERS (1 << 6)
00068 #define ARES_OPT_DOMAINS (1 << 7)
00069 #define ARES_OPT_LOOKUPS (1 << 8)
00070
00071 struct ares_options {
00072 int flags;
00073 int timeout;
00074 int tries;
00075 int ndots;
00076 unsigned short udp_port;
00077 unsigned short tcp_port;
00078 struct in_addr *servers;
00079 int nservers;
00080 char **domains;
00081 int ndomains;
00082 char *lookups;
00083 };
00084
00085 struct ares_channeldata;
00086 typedef struct ares_channeldata *ares_channel;
00087 typedef void (*ares_callback)(void *arg, int status, unsigned char *abuf,
00088 int alen);
00089 typedef void (*ares_host_callback)(void *arg, int status,
00090 struct hostent *hostent);
00091
00092 int ares_init(ares_channel *channelptr);
00093 int ares_init_options(ares_channel *channelptr, struct ares_options *options,
00094 int optmask);
00095 void ares_destroy(ares_channel channel);
00096
00097 void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
00098 ares_callback callback, void *arg);
00099 void ares_query(ares_channel channel, const char *name, int dnsclass,
00100 int type, ares_callback callback, void *arg);
00101 void ares_search(ares_channel channel, const char *name, int dnsclass,
00102 int type, ares_callback callback, void *arg);
00103 void ares_gethostbyname(ares_channel channel, const char *name, int family,
00104 ares_host_callback callback, void *arg);
00105 void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
00106 int family, ares_host_callback callback, void *arg);
00107
00108 int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
00109 struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
00110 struct timeval *tv);
00111 void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
00112
00113 int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
00114 int rd, unsigned char **buf, int *buflen);
00115 int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
00116 int alen, char **s, int *enclen);
00117 int ares_parse_a_reply(const unsigned char *abuf, int alen,
00118 struct hostent **host);
00119 int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
00120 int addrlen, int family, struct hostent **host);
00121 void ares_free_string(unsigned char *str);
00122 void ares_free_hostent(struct hostent *host);
00123 const char *ares_strerror(int code, char **memptr);
00124 void ares_free_errmem(char *mem);
00125
00126 #endif