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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5038 - (hide annotations) (download)
Fri Jul 8 04:18:36 2005 UTC (14 years, 5 months ago) by sailesh
Original Path: main/sip/contrib/ares/ares.h
File MIME type: text/plain
File size: 7779 byte(s)
Fix for Mac OS X. On 10.2 we can't include nameser_compat. We check MAC_OS_X_VERSION_MIN_REQUIRED to see which version of the OS we're compiling against. Unfortunately this macro is not defined when compiling from the command line. Thus if it's not defined we're goign to assume that we're compiling on 10.3 ore greater.
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     #include <errno.h>
21 fluffy 3987 #include <WinSock2.h>
22 fluffy 1726 #include <io.h>
23     #include <string.h>
24     #include <stdio.h>
25 jason 2377 #endif
26    
27     #if defined(__APPLE__)
28 fluffy 2091 #include <arpa/nameser.h>
29 sailesh 5038 #if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_2)
30 fluffy 2091 #include <arpa/nameser_compat.h>
31 fluffy 1726 #endif
32 sailesh 5038 #endif
33 fluffy 1726
34 ryker 1479 #include <sys/types.h>
35 derek 3941 #ifndef WIN32
36     /* why was this commented out?! ah, it was a 'fix for windows' */
37     #include <netinet/in.h>
38     #endif
39 ryker 1479
40 fluffy 1726
41 derek 3941
42 ryker 1479 #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 rohan 3940 #ifdef HAS_IPV6
86     struct multiFamilyAddr {
87     u_int8_t family;
88     struct in6_addr addr6;
89     struct in_addr addr;
90     };
91     #endif
92    
93 ryker 1479 struct ares_options {
94     int flags;
95     int timeout;
96     int tries;
97     int ndots;
98     unsigned short udp_port;
99     unsigned short tcp_port;
100 rohan 3940 #ifdef HAS_IPV6
101     struct multiFamilyAddr *servers;
102     #else
103 ryker 1479 struct in_addr *servers;
104 rohan 3940 #endif
105 ryker 1479 int nservers;
106     char **domains;
107     int ndomains;
108     char *lookups;
109     };
110    
111     struct hostent;
112     struct timeval;
113     struct ares_channeldata;
114     typedef struct ares_channeldata *ares_channel;
115     typedef void (*ares_callback)(void *arg, int status, unsigned char *abuf,
116     int alen);
117     typedef void (*ares_host_callback)(void *arg, int status,
118     struct hostent *hostent);
119    
120     int ares_init(ares_channel *channelptr);
121     int ares_init_options(ares_channel *channelptr, struct ares_options *options,
122     int optmask);
123     void ares_destroy(ares_channel channel);
124    
125     void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
126     ares_callback callback, void *arg);
127     void ares_query(ares_channel channel, const char *name, int dnsclass,
128     int type, ares_callback callback, void *arg);
129     void ares_search(ares_channel channel, const char *name, int dnsclass,
130     int type, ares_callback callback, void *arg);
131     void ares_gethostbyname(ares_channel channel, const char *name, int family,
132     ares_host_callback callback, void *arg);
133     void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
134     int family, ares_host_callback callback, void *arg);
135    
136     int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
137     struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
138     struct timeval *tv);
139     void ares_process(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
140    
141     int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
142     int rd, unsigned char **buf, int *buflen);
143     int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
144     int alen, char **s, int *enclen);
145     int ares_parse_a_reply(const unsigned char *abuf, int alen,
146     struct hostent **host);
147     int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
148     int addrlen, int family, struct hostent **host);
149     void ares_free_string(char *str);
150     void ares_free_hostent(struct hostent *host);
151 derek 3742 const char *ares_strerror(int code);
152 ryker 1479 void ares_free_errmem(char *mem);
153    
154 fluffy 2091
155 adamr 2078 #if defined(WIN32) || defined (__CYGWIN__)
156 fluffy 1728
157 fluffy 1726 #define T_A 1 /* host address */
158     #define T_NS 2 /* authoritative server */
159     #define T_MD 3 /* mail destination */
160     #define T_MF 4 /* mail forwarder */
161     #define T_CNAME 5 /* canonical name */
162     #define T_SOA 6 /* start of authority zone */
163     #define T_MB 7 /* mailbox domain name */
164     #define T_MG 8 /* mail group member */
165     #define T_MR 9 /* mail rename name */
166     #define T_NULL 10 /* null resource record */
167     #define T_WKS 11 /* well known service */
168     #define T_PTR 12 /* domain name pointer */
169     #define T_HINFO 13 /* host information */
170     #define T_MINFO 14 /* mailbox information */
171     #define T_MX 15 /* mail routing information */
172     #define T_TXT 16 /* text strings */
173     #define T_RP 17 /* responsible person */
174     #define T_AFSDB 18 /* AFS cell database */
175     #define T_X25 19 /* X_25 calling address */
176     #define T_ISDN 20 /* ISDN calling address */
177     #define T_RT 21 /* router */
178     #define T_NSAP 22 /* NSAP address */
179     #define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
180     #define T_SIG 24 /* security signature */
181     #define T_KEY 25 /* security key */
182     #define T_PX 26 /* X.400 mail mapping */
183     #define T_GPOS 27 /* geographical position (withdrawn) */
184     #define T_AAAA 28 /* IP6 Address */
185     #define T_LOC 29 /* Location Information */
186     /* non standard */
187     #define T_UINFO 100 /* user (finger) information */
188     #define T_UID 101 /* user ID */
189     #define T_GID 102 /* group ID */
190     #define T_UNSPEC 103 /* Unspecified format (binary data) */
191     /* Query type values which do not appear in resource records */
192     #define T_AXFR 252 /* transfer zone of authority */
193     #define T_MAILB 253 /* transfer mailbox records */
194     #define T_MAILA 254 /* transfer mail agent records */
195     #define T_ANY 255 /* wildcard match */
196    
197    
198     #define C_IN 1
199     #define C_CHAOS 3
200     #define C_HS 4
201     #define C_ANY 255
202    
203     #define INDIR_MASK 0xc0
204     #define HFIXEDSZ 12
205     #define QFIXEDSZ 4
206     #define RRFIXEDSZ 10
207    
208     #define NOERROR 0
209     #define FORMERR 1
210     #define SERVFAIL 2
211     #define NXDOMAIN 3
212     #define NOTIMP 4
213     #define REFUSED 5
214    
215     #define PACKETSZ 512
216 adamr 2090
217     #ifndef MAXHOSTNAMELEN
218 fluffy 1726 #define MAXHOSTNAMELEN 256
219 adamr 2090 #endif
220 fluffy 1726
221 adamr 2089 #define NS_DEFAULTPORT 53
222     #define NAMESERVER_PORT NS_DEFAULTPORT
223 fluffy 1726
224     #define QUERY 0
225     #define MAXLABEL 63
226    
227 fluffy 1728 #endif
228 fluffy 1726
229 ryker 1479 #endif /* ARES__H */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27