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

Contents of /main/contrib/ares/ares.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3880 - (show annotations) (download)
Thu Feb 10 20:56:07 2005 UTC (14 years, 9 months ago) by derek
Original Path: main/sip/contrib/ares/ares.h
File MIME type: text/plain
File size: 7400 byte(s)
fixed ares socket leak on windows: close vs socketclose
got rid of annoying cvs version lines
1 /* 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 #ifdef WIN32
20 #include <errno.h>
21 #include <winsock2.h>
22 #include <io.h>
23 #include <string.h>
24 #include <stdio.h>
25 #endif
26
27 #if defined(__APPLE__)
28 #include <arpa/nameser.h>
29 #include <arpa/nameser_compat.h>
30 #endif
31
32 #include <sys/types.h>
33 //#include <netinet/in.h>
34
35
36 #define ARES_SUCCESS 0
37
38 /* Server error codes (ARES_ENODATA indicates no relevant answer) */
39 #define ARES_ENODATA 1
40 #define ARES_EFORMERR 2
41 #define ARES_ESERVFAIL 3
42 #define ARES_ENOTFOUND 4
43 #define ARES_ENOTIMP 5
44 #define ARES_EREFUSED 6
45
46 /* Locally generated error codes */
47 #define ARES_EBADQUERY 7
48 #define ARES_EBADNAME 8
49 #define ARES_EBADFAMILY 9
50 #define ARES_EBADRESP 10
51 #define ARES_ECONNREFUSED 11
52 #define ARES_ETIMEOUT 12
53 #define ARES_EOF 13
54 #define ARES_EFILE 14
55 #define ARES_ENOMEM 15
56 #define ARES_EDESTRUCTION 16
57
58 /* Flag values */
59 #define ARES_FLAG_USEVC (1 << 0)
60 #define ARES_FLAG_PRIMARY (1 << 1)
61 #define ARES_FLAG_IGNTC (1 << 2)
62 #define ARES_FLAG_NORECURSE (1 << 3)
63 #define ARES_FLAG_STAYOPEN (1 << 4)
64 #define ARES_FLAG_NOSEARCH (1 << 5)
65 #define ARES_FLAG_NOALIASES (1 << 6)
66 #define ARES_FLAG_NOCHECKRESP (1 << 7)
67
68 /* Option mask values */
69 #define ARES_OPT_FLAGS (1 << 0)
70 #define ARES_OPT_TIMEOUT (1 << 1)
71 #define ARES_OPT_TRIES (1 << 2)
72 #define ARES_OPT_NDOTS (1 << 3)
73 #define ARES_OPT_UDP_PORT (1 << 4)
74 #define ARES_OPT_TCP_PORT (1 << 5)
75 #define ARES_OPT_SERVERS (1 << 6)
76 #define ARES_OPT_DOMAINS (1 << 7)
77 #define ARES_OPT_LOOKUPS (1 << 8)
78
79 struct ares_options {
80 int flags;
81 int timeout;
82 int tries;
83 int ndots;
84 unsigned short udp_port;
85 unsigned short tcp_port;
86 struct in_addr *servers;
87 int nservers;
88 char **domains;
89 int ndomains;
90 char *lookups;
91 };
92
93 struct hostent;
94 struct timeval;
95 struct ares_channeldata;
96 typedef struct ares_channeldata *ares_channel;
97 typedef void (*ares_callback)(void *arg, int status, unsigned char *abuf,
98 int alen);
99 typedef void (*ares_host_callback)(void *arg, int status,
100 struct hostent *hostent);
101
102 int ares_init(ares_channel *channelptr);
103 int ares_init_options(ares_channel *channelptr, struct ares_options *options,
104 int optmask);
105 void ares_destroy(ares_channel channel);
106
107 void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
108 ares_callback callback, void *arg);
109 void ares_query(ares_channel channel, const char *name, int dnsclass,
110 int type, ares_callback callback, void *arg);
111 void ares_search(ares_channel channel, const char *name, int dnsclass,
112 int type, ares_callback callback, void *arg);
113 void ares_gethostbyname(ares_channel channel, const char *name, int family,
114 ares_host_callback callback, void *arg);
115 void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
116 int family, ares_host_callback callback, void *arg);
117
118 int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
119 struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
120 struct timeval *tv);
121 void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
122
123 int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
124 int rd, unsigned char **buf, int *buflen);
125 int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
126 int alen, char **s, int *enclen);
127 int ares_parse_a_reply(const unsigned char *abuf, int alen,
128 struct hostent **host);
129 int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
130 int addrlen, int family, struct hostent **host);
131 void ares_free_string(char *str);
132 void ares_free_hostent(struct hostent *host);
133 const char *ares_strerror(int code);
134 void ares_free_errmem(char *mem);
135
136
137 #if defined(WIN32) || defined (__CYGWIN__)
138
139 #define T_A 1 /* host address */
140 #define T_NS 2 /* authoritative server */
141 #define T_MD 3 /* mail destination */
142 #define T_MF 4 /* mail forwarder */
143 #define T_CNAME 5 /* canonical name */
144 #define T_SOA 6 /* start of authority zone */
145 #define T_MB 7 /* mailbox domain name */
146 #define T_MG 8 /* mail group member */
147 #define T_MR 9 /* mail rename name */
148 #define T_NULL 10 /* null resource record */
149 #define T_WKS 11 /* well known service */
150 #define T_PTR 12 /* domain name pointer */
151 #define T_HINFO 13 /* host information */
152 #define T_MINFO 14 /* mailbox information */
153 #define T_MX 15 /* mail routing information */
154 #define T_TXT 16 /* text strings */
155 #define T_RP 17 /* responsible person */
156 #define T_AFSDB 18 /* AFS cell database */
157 #define T_X25 19 /* X_25 calling address */
158 #define T_ISDN 20 /* ISDN calling address */
159 #define T_RT 21 /* router */
160 #define T_NSAP 22 /* NSAP address */
161 #define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
162 #define T_SIG 24 /* security signature */
163 #define T_KEY 25 /* security key */
164 #define T_PX 26 /* X.400 mail mapping */
165 #define T_GPOS 27 /* geographical position (withdrawn) */
166 #define T_AAAA 28 /* IP6 Address */
167 #define T_LOC 29 /* Location Information */
168 /* non standard */
169 #define T_UINFO 100 /* user (finger) information */
170 #define T_UID 101 /* user ID */
171 #define T_GID 102 /* group ID */
172 #define T_UNSPEC 103 /* Unspecified format (binary data) */
173 /* Query type values which do not appear in resource records */
174 #define T_AXFR 252 /* transfer zone of authority */
175 #define T_MAILB 253 /* transfer mailbox records */
176 #define T_MAILA 254 /* transfer mail agent records */
177 #define T_ANY 255 /* wildcard match */
178
179
180 #define C_IN 1
181 #define C_CHAOS 3
182 #define C_HS 4
183 #define C_ANY 255
184
185 #define INDIR_MASK 0xc0
186 #define HFIXEDSZ 12
187 #define QFIXEDSZ 4
188 #define RRFIXEDSZ 10
189
190 #define NOERROR 0
191 #define FORMERR 1
192 #define SERVFAIL 2
193 #define NXDOMAIN 3
194 #define NOTIMP 4
195 #define REFUSED 5
196
197 #define PACKETSZ 512
198
199 #ifndef MAXHOSTNAMELEN
200 #define MAXHOSTNAMELEN 256
201 #endif
202
203 #define NS_DEFAULTPORT 53
204 #define NAMESERVER_PORT NS_DEFAULTPORT
205
206 #define QUERY 0
207 #define MAXLABEL 63
208
209 #endif
210
211 #endif /* ARES__H */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27