/[resiprocate]/main/contrib/ares/ares.h
ViewVC logotype

Annotation of /main/contrib/ares/ares.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5272 - (hide annotations) (download)
Thu Aug 18 23:49:50 2005 UTC (14 years, 3 months ago) by jason
Original Path: branches/b-directory-reorg/contrib/ares/ares.h
File MIME type: text/plain
File size: 7974 byte(s)
initial reorg - more to come
1 ryker 1479 /* Copyright 1998 by the Massachusetts Institute of Technology.
2     *
3     * Permission to use, copy, modify, and distribute this
4     * software and its documentation for any purpose and without
5     * fee is hereby granted, provided that the above copyright
6     * notice appear in all copies and that both that copyright
7     * notice and this permission notice appear in supporting
8     * documentation, and that the name of M.I.T. not be used in
9     * advertising or publicity pertaining to distribution of the
10     * software without specific, written prior permission.
11     * M.I.T. makes no representations about the suitability of
12     * this software for any purpose. It is provided "as is"
13     * without express or implied warranty.
14     */
15    
16     #ifndef ARES__H
17     #define ARES__H
18    
19 fluffy 1726 #ifdef WIN32
20 derek 5268 #include <winsock2.h>
21     #include <stdlib.h>
22 fluffy 1726 #include <errno.h>
23     #include <io.h>
24     #include <string.h>
25     #include <stdio.h>
26 derek 5268 #include <Ws2tcpip.h>
27 jason 2377 #endif
28    
29     #if defined(__APPLE__)
30 fluffy 2091 #include <arpa/nameser.h>
31 sailesh 5038 #if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_2)
32 fluffy 2091 #include <arpa/nameser_compat.h>
33 fluffy 1726 #endif
34 sailesh 5038 #endif
35 fluffy 1726
36 ryker 1479 #include <sys/types.h>
37 derek 3941 #ifndef WIN32
38     /* why was this commented out?! ah, it was a 'fix for windows' */
39     #include <netinet/in.h>
40     #endif
41 ryker 1479
42     #define ARES_SUCCESS 0
43    
44     /* Server error codes (ARES_ENODATA indicates no relevant answer) */
45     #define ARES_ENODATA 1
46     #define ARES_EFORMERR 2
47     #define ARES_ESERVFAIL 3
48     #define ARES_ENOTFOUND 4
49     #define ARES_ENOTIMP 5
50     #define ARES_EREFUSED 6
51    
52     /* Locally generated error codes */
53     #define ARES_EBADQUERY 7
54     #define ARES_EBADNAME 8
55     #define ARES_EBADFAMILY 9
56     #define ARES_EBADRESP 10
57     #define ARES_ECONNREFUSED 11
58     #define ARES_ETIMEOUT 12
59     #define ARES_EOF 13
60     #define ARES_EFILE 14
61     #define ARES_ENOMEM 15
62     #define ARES_EDESTRUCTION 16
63    
64     /* Flag values */
65     #define ARES_FLAG_USEVC (1 << 0)
66     #define ARES_FLAG_PRIMARY (1 << 1)
67     #define ARES_FLAG_IGNTC (1 << 2)
68     #define ARES_FLAG_NORECURSE (1 << 3)
69     #define ARES_FLAG_STAYOPEN (1 << 4)
70     #define ARES_FLAG_NOSEARCH (1 << 5)
71     #define ARES_FLAG_NOALIASES (1 << 6)
72     #define ARES_FLAG_NOCHECKRESP (1 << 7)
73    
74     /* Option mask values */
75     #define ARES_OPT_FLAGS (1 << 0)
76     #define ARES_OPT_TIMEOUT (1 << 1)
77     #define ARES_OPT_TRIES (1 << 2)
78     #define ARES_OPT_NDOTS (1 << 3)
79     #define ARES_OPT_UDP_PORT (1 << 4)
80     #define ARES_OPT_TCP_PORT (1 << 5)
81     #define ARES_OPT_SERVERS (1 << 6)
82     #define ARES_OPT_DOMAINS (1 << 7)
83     #define ARES_OPT_LOOKUPS (1 << 8)
84    
85 derek 5269 /* Capability mask values */
86    
87     #define ARES_CAP_IPV6 (1 << 0)
88    
89 derek 5268 #ifdef WIN32
90     typedef unsigned char u_int8_t;
91     #endif
92 derek 5269
93 derek 5267 #ifdef USE_IPV6
94 rohan 3940 struct multiFamilyAddr {
95     u_int8_t family;
96     struct in6_addr addr6;
97     struct in_addr addr;
98     };
99     #endif
100    
101 ryker 1479 struct ares_options {
102     int flags;
103     int timeout;
104     int tries;
105     int ndots;
106     unsigned short udp_port;
107     unsigned short tcp_port;
108 derek 5267 #ifdef USE_IPV6
109 rohan 3940 struct multiFamilyAddr *servers;
110     #else
111 ryker 1479 struct in_addr *servers;
112 rohan 3940 #endif
113 ryker 1479 int nservers;
114     char **domains;
115     int ndomains;
116     char *lookups;
117     };
118    
119     struct hostent;
120     struct timeval;
121     struct ares_channeldata;
122     typedef struct ares_channeldata *ares_channel;
123     typedef void (*ares_callback)(void *arg, int status, unsigned char *abuf,
124     int alen);
125     typedef void (*ares_host_callback)(void *arg, int status,
126     struct hostent *hostent);
127    
128     int ares_init(ares_channel *channelptr);
129 derek 5269
130     int ares_capabilities(int capmask);
131    
132 ryker 1479 int ares_init_options(ares_channel *channelptr, struct ares_options *options,
133     int optmask);
134     void ares_destroy(ares_channel channel);
135    
136     void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
137     ares_callback callback, void *arg);
138     void ares_query(ares_channel channel, const char *name, int dnsclass,
139     int type, ares_callback callback, void *arg);
140     void ares_search(ares_channel channel, const char *name, int dnsclass,
141     int type, ares_callback callback, void *arg);
142     void ares_gethostbyname(ares_channel channel, const char *name, int family,
143     ares_host_callback callback, void *arg);
144     void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
145     int family, ares_host_callback callback, void *arg);
146    
147     int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
148     struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
149     struct timeval *tv);
150     void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
151    
152     int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
153     int rd, unsigned char **buf, int *buflen);
154     int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
155     int alen, char **s, int *enclen);
156     int ares_parse_a_reply(const unsigned char *abuf, int alen,
157     struct hostent **host);
158     int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
159     int addrlen, int family, struct hostent **host);
160     void ares_free_string(char *str);
161     void ares_free_hostent(struct hostent *host);
162 derek 3742 const char *ares_strerror(int code);
163 ryker 1479 void ares_free_errmem(char *mem);
164    
165 fluffy 2091
166 adamr 2078 #if defined(WIN32) || defined (__CYGWIN__)
167 fluffy 1728
168 fluffy 1726 #define T_A 1 /* host address */
169     #define T_NS 2 /* authoritative server */
170     #define T_MD 3 /* mail destination */
171     #define T_MF 4 /* mail forwarder */
172     #define T_CNAME 5 /* canonical name */
173     #define T_SOA 6 /* start of authority zone */
174     #define T_MB 7 /* mailbox domain name */
175     #define T_MG 8 /* mail group member */
176     #define T_MR 9 /* mail rename name */
177     #define T_NULL 10 /* null resource record */
178     #define T_WKS 11 /* well known service */
179     #define T_PTR 12 /* domain name pointer */
180     #define T_HINFO 13 /* host information */
181     #define T_MINFO 14 /* mailbox information */
182     #define T_MX 15 /* mail routing information */
183     #define T_TXT 16 /* text strings */
184     #define T_RP 17 /* responsible person */
185     #define T_AFSDB 18 /* AFS cell database */
186     #define T_X25 19 /* X_25 calling address */
187     #define T_ISDN 20 /* ISDN calling address */
188     #define T_RT 21 /* router */
189     #define T_NSAP 22 /* NSAP address */
190     #define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
191     #define T_SIG 24 /* security signature */
192     #define T_KEY 25 /* security key */
193     #define T_PX 26 /* X.400 mail mapping */
194     #define T_GPOS 27 /* geographical position (withdrawn) */
195     #define T_AAAA 28 /* IP6 Address */
196     #define T_LOC 29 /* Location Information */
197     /* non standard */
198     #define T_UINFO 100 /* user (finger) information */
199     #define T_UID 101 /* user ID */
200     #define T_GID 102 /* group ID */
201     #define T_UNSPEC 103 /* Unspecified format (binary data) */
202     /* Query type values which do not appear in resource records */
203     #define T_AXFR 252 /* transfer zone of authority */
204     #define T_MAILB 253 /* transfer mailbox records */
205     #define T_MAILA 254 /* transfer mail agent records */
206     #define T_ANY 255 /* wildcard match */
207    
208    
209     #define C_IN 1
210     #define C_CHAOS 3
211     #define C_HS 4
212     #define C_ANY 255
213    
214     #define INDIR_MASK 0xc0
215     #define HFIXEDSZ 12
216     #define QFIXEDSZ 4
217     #define RRFIXEDSZ 10
218    
219     #define NOERROR 0
220     #define FORMERR 1
221     #define SERVFAIL 2
222     #define NXDOMAIN 3
223     #define NOTIMP 4
224     #define REFUSED 5
225    
226     #define PACKETSZ 512
227 adamr 2090
228     #ifndef MAXHOSTNAMELEN
229 fluffy 1726 #define MAXHOSTNAMELEN 256
230 adamr 2090 #endif
231 fluffy 1726
232 adamr 2089 #define NS_DEFAULTPORT 53
233     #define NAMESERVER_PORT NS_DEFAULTPORT
234 fluffy 1726
235     #define QUERY 0
236     #define MAXLABEL 63
237    
238 fluffy 1728 #endif
239 fluffy 1726
240 ryker 1479 #endif /* ARES__H */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27