Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 260 lines (230 sloc) 9.476 kB
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
1 /* $Id$ */
2
3 /* Copyright 1998 by the Massachusetts Institute of Technology.
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for any purpose and without
7 * fee is hereby granted, provided that the above copyright
8 * notice appear in all copies and that both that copyright
9 * notice and this permission notice appear in supporting
10 * documentation, and that the name of M.I.T. not be used in
11 * advertising or publicity pertaining to distribution of the
12 * software without specific, written prior permission.
13 * M.I.T. makes no representations about the suitability of
14 * this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
16 */
17
18 #ifndef ARES__H
19 #define ARES__H
20
7cd35ce @yangtse Define WIN32 when build target is Win32 API.
yangtse authored
21 /*
22 * Define WIN32 when build target is Win32 API
23 */
24
25 #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
26 #define WIN32
27 #endif
28
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
29 #include <sys/types.h>
30
316c126 @gknauf few minor changes to make ares compile for NetWare CLIB architecture.
gknauf authored
31 #if defined(_AIX) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
ff2794f @bagder Don't check for HAVE_ defines in this header file, it is meant to be …
bagder authored
32 /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
33 libc5-based Linux systems. Only include it on system that are known to
34 require it! */
27126cb @bagder include sys/select.h
bagder authored
35 #include <sys/select.h>
36 #endif
9837d91 @gknauf added NetWare CLIB-own header to solve gcc warnings.
gknauf authored
37 #if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
38 #include <sys/bsdskt.h>
39 #endif
27126cb @bagder include sys/select.h
bagder authored
40
6deb40a Changes for Watt-32 on Windows. I've assumed Configure
Gisle Vanem authored
41 #if defined(WATT32)
42 #include <netinet/in.h>
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
43 #include <sys/socket.h>
6deb40a Changes for Watt-32 on Windows. I've assumed Configure
Gisle Vanem authored
44 #include <tcp.h>
298541c @yangtse Remove redundant __CYGWIN__ symbol check
yangtse authored
45 #elif defined(WIN32)
c43edeb @yangtse Undo previous change. This header file belongs to the public
yangtse authored
46 #include <winsock2.h>
47 #include <windows.h>
48 #else
6deb40a Changes for Watt-32 on Windows. I've assumed Configure
Gisle Vanem authored
49 #include <netinet/in.h>
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
50 #include <sys/socket.h>
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
51 #endif
52
7319c3a Adapted for C++.
Gisle Vanem authored
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
57 #define ARES_SUCCESS 0
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
58
59 /* Server error codes (ARES_ENODATA indicates no relevant answer) */
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
60 #define ARES_ENODATA 1
61 #define ARES_EFORMERR 2
62 #define ARES_ESERVFAIL 3
63 #define ARES_ENOTFOUND 4
64 #define ARES_ENOTIMP 5
65 #define ARES_EREFUSED 6
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
66
67 /* Locally generated error codes */
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
68 #define ARES_EBADQUERY 7
69 #define ARES_EBADNAME 8
70 #define ARES_EBADFAMILY 9
71 #define ARES_EBADRESP 10
72 #define ARES_ECONNREFUSED 11
73 #define ARES_ETIMEOUT 12
74 #define ARES_EOF 13
75 #define ARES_EFILE 14
76 #define ARES_ENOMEM 15
77 #define ARES_EDESTRUCTION 16
78 #define ARES_EBADSTR 17
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
79
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
80 /* ares_getnameinfo error codes */
b117fef @bagder detabified
bagder authored
81 #define ARES_EBADFLAGS 18
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
82
6afd5c1 Added constants that will be used by ares_getaddrinfo. Made ares_getn…
Dominick Meglio authored
83 /* ares_getaddrinfo error codes */
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
84 #define ARES_ENONAME 19
85 #define ARES_EBADHINTS 20
6afd5c1 Added constants that will be used by ares_getaddrinfo. Made ares_getn…
Dominick Meglio authored
86
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
87 /* Flag values */
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
88 #define ARES_FLAG_USEVC (1 << 0)
89 #define ARES_FLAG_PRIMARY (1 << 1)
90 #define ARES_FLAG_IGNTC (1 << 2)
91 #define ARES_FLAG_NORECURSE (1 << 3)
92 #define ARES_FLAG_STAYOPEN (1 << 4)
93 #define ARES_FLAG_NOSEARCH (1 << 5)
94 #define ARES_FLAG_NOALIASES (1 << 6)
95 #define ARES_FLAG_NOCHECKRESP (1 << 7)
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
96
97 /* Option mask values */
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
98 #define ARES_OPT_FLAGS (1 << 0)
99 #define ARES_OPT_TIMEOUT (1 << 1)
100 #define ARES_OPT_TRIES (1 << 2)
101 #define ARES_OPT_NDOTS (1 << 3)
102 #define ARES_OPT_UDP_PORT (1 << 4)
103 #define ARES_OPT_TCP_PORT (1 << 5)
104 #define ARES_OPT_SERVERS (1 << 6)
105 #define ARES_OPT_DOMAINS (1 << 7)
106 #define ARES_OPT_LOOKUPS (1 << 8)
22e34b5 @bagder Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set …
bagder authored
107 #define ARES_OPT_SOCK_STATE_CB (1 << 9)
f1440b2 @bagder Brad House added ares_save_options() and ares_destroy_options() that …
bagder authored
108 #define ARES_OPT_SORTLIST (1 << 10)
56ffdce @sesse Support a few more socket options, and refactor the option setting a …
sesse authored
109 #define ARES_OPT_SOCK_SNDBUF (1 << 11)
110 #define ARES_OPT_SOCK_RCVBUF (1 << 12)
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
111
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
112 /* Nameinfo flag values */
b117fef @bagder detabified
bagder authored
113 #define ARES_NI_NOFQDN (1 << 0)
114 #define ARES_NI_NUMERICHOST (1 << 1)
115 #define ARES_NI_NAMEREQD (1 << 2)
116 #define ARES_NI_NUMERICSERV (1 << 3)
117 #define ARES_NI_DGRAM (1 << 4)
118 #define ARES_NI_TCP 0
119 #define ARES_NI_UDP ARES_NI_DGRAM
120 #define ARES_NI_SCTP (1 << 5)
121 #define ARES_NI_DCCP (1 << 6)
122 #define ARES_NI_NUMERICSCOPE (1 << 7)
123 #define ARES_NI_LOOKUPHOST (1 << 8)
124 #define ARES_NI_LOOKUPSERVICE (1 << 9)
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
125 /* Reserved for future use */
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
126 #define ARES_NI_IDN (1 << 10)
127 #define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
6afd5c1 Added constants that will be used by ares_getaddrinfo. Made ares_getn…
Dominick Meglio authored
128 #define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
129
130 /* Addrinfo flag values */
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
131 #define ARES_AI_CANONNAME (1 << 0)
132 #define ARES_AI_NUMERICHOST (1 << 1)
133 #define ARES_AI_PASSIVE (1 << 2)
134 #define ARES_AI_NUMERICSERV (1 << 3)
135 #define ARES_AI_V4MAPPED (1 << 4)
136 #define ARES_AI_ALL (1 << 5)
137 #define ARES_AI_ADDRCONFIG (1 << 6)
6afd5c1 Added constants that will be used by ares_getaddrinfo. Made ares_getn…
Dominick Meglio authored
138 /* Reserved for future use */
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
139 #define ARES_AI_IDN (1 << 10)
140 #define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
6afd5c1 Added constants that will be used by ares_getaddrinfo. Made ares_getn…
Dominick Meglio authored
141 #define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
142 #define ARES_AI_CANONIDN (1 << 13)
6afd5c1 Added constants that will be used by ares_getaddrinfo. Made ares_getn…
Dominick Meglio authored
143
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
144 #define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
145 ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
146 ARES_AI_ADDRCONFIG)
147 #define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about this
148 many sockets */
149 #define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
150 #define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + \
151 ARES_GETSOCK_MAXNUM)))
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
152
8c35c65 @bagder added ares_process_fd() to allow applications to ask for processing on
bagder authored
153
154 /*
155 * Typedef our socket type
156 */
157
158 #ifndef ares_socket_typedef
159 #ifdef WIN32
160 typedef SOCKET ares_socket_t;
161 #define ARES_SOCKET_BAD INVALID_SOCKET
162 #else
163 typedef int ares_socket_t;
164 #define ARES_SOCKET_BAD -1
165 #endif
166 #define ares_socket_typedef
167 #endif /* ares_socket_typedef */
168
22e34b5 @bagder Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set …
bagder authored
169 typedef void (*ares_sock_state_cb)(void *data,
e2d8092 @yangtse Avoid shadowing a global declaration
yangtse authored
170 ares_socket_t socket_fd,
22e34b5 @bagder Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set …
bagder authored
171 int readable,
172 int writable);
173
f1440b2 @bagder Brad House added ares_save_options() and ares_destroy_options() that …
bagder authored
174 struct apattern;
175
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
176 struct ares_options {
177 int flags;
178 int timeout;
179 int tries;
180 int ndots;
181 unsigned short udp_port;
182 unsigned short tcp_port;
56ffdce @sesse Support a few more socket options, and refactor the option setting a …
sesse authored
183 int socket_send_buffer_size;
184 int socket_receive_buffer_size;
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
185 struct in_addr *servers;
186 int nservers;
187 char **domains;
188 int ndomains;
189 char *lookups;
22e34b5 @bagder Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set …
bagder authored
190 ares_sock_state_cb sock_state_cb;
191 void *sock_state_cb_data;
f1440b2 @bagder Brad House added ares_save_options() and ares_destroy_options() that …
bagder authored
192 struct apattern *sortlist;
193 int nsort;
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
194 };
195
196 struct hostent;
197 struct timeval;
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
198 struct sockaddr;
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
199 struct ares_channeldata;
200 typedef struct ares_channeldata *ares_channel;
50ba81c @sesse Make the query callbacks return the number of timeouts that happened …
sesse authored
201 typedef void (*ares_callback)(void *arg, int status, int timeouts,
202 unsigned char *abuf, int alen);
203 typedef void (*ares_host_callback)(void *arg, int status, int timeouts,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
204 struct hostent *hostent);
50ba81c @sesse Make the query callbacks return the number of timeouts that happened …
sesse authored
205 typedef void (*ares_nameinfo_callback)(void *arg, int status, int timeouts,
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
206 char *node, char *service);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
207
208 int ares_init(ares_channel *channelptr);
209 int ares_init_options(ares_channel *channelptr, struct ares_options *options,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
210 int optmask);
f1440b2 @bagder Brad House added ares_save_options() and ares_destroy_options() that …
bagder authored
211 int ares_save_options(ares_channel channel, struct ares_options *options, int *optmask);
212 void ares_destroy_options(struct ares_options *options);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
213 void ares_destroy(ares_channel channel);
86ae234 @bagder Dirk Manske's ares_cancel() function was added.
bagder authored
214 void ares_cancel(ares_channel channel);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
215 void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
216 ares_callback callback, void *arg);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
217 void ares_query(ares_channel channel, const char *name, int dnsclass,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
218 int type, ares_callback callback, void *arg);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
219 void ares_search(ares_channel channel, const char *name, int dnsclass,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
220 int type, ares_callback callback, void *arg);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
221 void ares_gethostbyname(ares_channel channel, const char *name, int family,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
222 ares_host_callback callback, void *arg);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
223 void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
224 int family, ares_host_callback callback, void *arg);
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
225 void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
226 socklen_t salen, int flags,
227 ares_nameinfo_callback callback,
aba0b77 Added ares_getnameinfo which mimics the getnameinfo API
Dominick Meglio authored
228 void *arg);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
229 int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
8d63eb7 @bagder Added ares_getsock() to extract sockets to wait for action on, withou…
bagder authored
230 int ares_getsock(ares_channel channel, int *socks, int numsocks);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
231 struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
232 struct timeval *tv);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
233 void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
8c35c65 @bagder added ares_process_fd() to allow applications to ask for processing on
bagder authored
234 void ares_process_fd(ares_channel channel, ares_socket_t read_fd,
235 ares_socket_t write_fd);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
236
237 int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
238 int rd, unsigned char **buf, int *buflen);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
239 int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
240 int alen, char **s, long *enclen);
af26fa5 @bagder Dominick Meglio's new ares_expand_string() function
bagder authored
241 int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
242 int alen, unsigned char **s, long *enclen);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
243 int ares_parse_a_reply(const unsigned char *abuf, int alen,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
244 struct hostent **host);
9586905 @bagder Dominick Meglio added ares_parse_aaaa_reply.c and did various adjustm…
bagder authored
245 int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
246 struct hostent **host);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
247 int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
3e748f4 @bagder removed tabs and trailing whitespace from source
bagder authored
248 int addrlen, int family, struct hostent **host);
c1bc4c1 @bagder Vlad Dinulescu added ares_parse_ns_reply()
bagder authored
249 int ares_parse_ns_reply(const unsigned char *abuf, int alen,
250 struct hostent **host);
72b499b @bagder ares_free_string() now takes a void * instead
bagder authored
251 void ares_free_string(void *str);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
252 void ares_free_hostent(struct hostent *host);
3ac93aa @bagder removed the silly second argument to ares_strerror()
bagder authored
253 const char *ares_strerror(int code);
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
254
7319c3a Adapted for C++.
Gisle Vanem authored
255 #ifdef __cplusplus
256 }
257 #endif
258
5e847a1 @bagder ares 1.1.1 with collected applied patches
bagder authored
259 #endif /* ARES__H */
Something went wrong with that request. Please try again.