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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3987 - (hide annotations) (download)
Sun Mar 13 21:53:08 2005 UTC (14 years, 9 months ago) by fluffy
Original Path: main/sip/contrib/ares/ares.h
File MIME type: text/plain
File size: 7669 byte(s)


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

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27