e17e28e338a7aad22359e0ebd37e374c8da535ff
[oftp] / libs / watt32 / resolv.h
1 /*!\file resolv.h
2  * Resolver API.
3  */
4
5 /*-
6  * Copyright (c) 1983, 1987, 1989, 1993
7  *      The Regents of the University of California.  All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by the University of
20  *      California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  * -
38  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
39  *
40  * Permission to use, copy, modify, and distribute this software for any
41  * purpose with or without fee is hereby granted, provided that the above
42  * copyright notice and this permission notice appear in all copies, and that
43  * the name of Digital Equipment Corporation not be used in advertising or
44  * publicity pertaining to distribution of the document or software without
45  * specific, written prior permission.
46  *
47  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
48  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
49  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
50  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
51  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
52  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
53  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
54  * SOFTWARE.
55  * -
56  * --Copyright--
57  *
58  *      @(#)resolv.h    8.1 (Berkeley) 6/2/93
59  *      From Id: resolv.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp
60  *      $Id: resolv.h,v 1.7 1996/08/29 20:00:58 peter Exp $
61  */
62
63 #ifndef _RESOLV_H_
64 #define _RESOLV_H_
65
66 #include <stdio.h>
67
68 #ifndef __SYS_W32API_H
69 #include <sys/w32api.h>
70 #endif
71
72 #ifndef __SYS_PARAM_H
73 #include <sys/param.h>
74 #endif
75
76 #ifndef __SYS_WTYPES_H
77 #include <sys/wtypes.h>
78 #endif
79
80 #ifndef __SYS_CDEFS_H
81 #include <sys/cdefs.h>
82 #endif
83
84
85 /*
86  * revision information.  this is the release date in YYYYMMDD format.
87  * it can change every day so the right thing to do with it is use it
88  * in preprocessor commands such as "#if (__RES > 19931104)".  do not
89  * compare for equality; rather, use it to determine whether your resolver
90  * is new enough to contain a certain feature.
91  */
92
93 #define __RES   19960229
94
95 /*
96  * Resolver configuration file.
97  * Normally not present, but may contain the address of the
98  * inital name server(s) to query and the domain search list.
99  */
100
101 #ifndef _PATH_RESCONF
102 #define _PATH_RESCONF   "/etc/resolv.conf"
103 #endif
104
105 /*
106  * Global defines and variables for resolver stub.
107  */
108 #define MAXNS                   3       /* max # name servers we'll track */
109 #define MAXDFLSRCH              3       /* # default domain levels to try */
110 #define MAXDNSRCH               6       /* max # domains in search path */
111 #define LOCALDOMAINPARTS        2       /* min levels in name that is "local" */
112
113 #define RES_TIMEOUT             5       /* min. seconds between retries */
114 #define MAXRESOLVSORT           10      /* number of net to sort on */
115 #define RES_MAXNDOTS            15      /* should reflect bit field size */
116
117 struct __res_state {
118         int      retrans;               /* retransmition time interval */
119         int      retry;                 /* number of times to retransmit */
120         u_long   options;               /* option flags - see below. */
121         int      nscount;               /* number of name servers */
122         struct   sockaddr_in
123                  nsaddr_list[MAXNS];    /* address of name server */
124 #define nsaddr   nsaddr_list[0]         /* for backward compatibility */
125         u_short  id;                    /* current packet id */
126         char    *dnsrch[MAXDNSRCH+1];   /* components of domain to search */
127         char     defdname[MAXDNAME];    /* default domain */
128         u_long   pfcode;                /* RES_PRF_ flags - see below. */
129         unsigned ndots:4;               /* threshold for initial abs. query */
130         unsigned nsort:4;               /* number of elements in sort_list[] */
131         char    unused[3];
132         struct {
133           struct in_addr  addr;
134           u_long          mask;
135       } sort_list[MAXRESOLVSORT];
136         char pad[72];                   /* On an i386 this means 512b total. */
137 };
138
139 /*
140  * Resolver options (keep these in synch with res_debug.c, please)
141  */
142 #define RES_INIT        0x00000001      /* address initialized */
143 #define RES_DEBUG       0x00000002      /* print debug messages */
144 #define RES_AAONLY      0x00000004      /* authoritative answers only (!IMPL)*/
145 #define RES_USEVC       0x00000008      /* use virtual circuit */
146 #define RES_PRIMARY     0x00000010      /* query primary server only (!IMPL) */
147 #define RES_IGNTC       0x00000020      /* ignore truncation errors */
148 #define RES_RECURSE     0x00000040      /* recursion desired */
149 #define RES_DEFNAMES    0x00000080      /* use default domain name */
150 #define RES_STAYOPEN    0x00000100      /* Keep TCP socket open */
151 #define RES_DNSRCH      0x00000200      /* search up local domain tree */
152 #define RES_INSECURE1   0x00000400      /* type 1 security disabled */
153 #define RES_INSECURE2   0x00000800      /* type 2 security disabled */
154 #define RES_NOALIASES   0x00001000      /* shuts off HOSTALIASES feature */
155 #define RES_USE_INET6   0x00002000      /* use/map IPv6 in gethostbyname() */
156
157 #define RES_DEFAULT     (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
158
159 /*
160  * Resolver "pfcode" values.  Used by dig.
161  */
162 #define RES_PRF_STATS   0x00000001
163 /*                      0x00000002      */
164 #define RES_PRF_CLASS   0x00000004
165 #define RES_PRF_CMD     0x00000008
166 #define RES_PRF_QUES    0x00000010
167 #define RES_PRF_ANS     0x00000020
168 #define RES_PRF_AUTH    0x00000040
169 #define RES_PRF_ADD     0x00000080
170 #define RES_PRF_HEAD1   0x00000100
171 #define RES_PRF_HEAD2   0x00000200
172 #define RES_PRF_TTLID   0x00000400
173 #define RES_PRF_HEADX   0x00000800
174 #define RES_PRF_QUERY   0x00001000
175 #define RES_PRF_REPLY   0x00002000
176 #define RES_PRF_INIT    0x00004000
177 /*                      0x00008000      */
178
179 /* hooks are still experimental as of 4.9.2 */
180 typedef enum {
181         res_goahead,
182         res_nextns,
183         res_modified,
184         res_done,
185         res_error
186       } res_sendhookact;
187
188 typedef res_sendhookact (*res_send_qhook)(struct sockaddr_in * const *ns,
189                                           const u_char **query,
190                                           int *querylen,
191                                           u_char *ans,
192                                           int anssiz,
193                                           int *resplen);
194
195 typedef res_sendhookact (*res_send_rhook)(const struct sockaddr_in *ns,
196                                           const u_char *query,
197                                           int querylen,
198                                           u_char *ans,
199                                           int anssiz,
200                                           int *resplen);
201
202 W32_DATA struct __res_state _res;
203
204 W32_DATA int h_errno;
205
206 /* Private routines shared between libc/net, named, nslookup and others. */
207 #define res_hnok         __res_hnok
208 #define res_ownok        __res_ownok
209 #define res_mailok       __res_mailok
210 #define res_dnok         __res_dnok
211 #define loc_ntoa         __loc_ntoa
212 #define loc_aton         __loc_aton
213 #define dn_skipname      __dn_skipname
214 #define fp_query         __fp_query
215 #define fp_nquery        __fp_nquery
216 #define hostalias        __hostalias
217 #define putlong          __putlong
218 #define putshort         __putshort
219 #define p_class          __p_class
220 #define p_time           __p_time
221 #define p_type           __p_type
222 #define p_cdnname        __p_cdnname
223 #define p_cdname         __p_cdname
224 #define p_fqname         __p_fqname
225 #define p_rr             __p_rr
226 #define p_option         __p_option
227 #define res_randomid     __res_randomid
228 #define res_isourserver  __res_isourserver
229 #define res_nameinquery  __res_nameinquery
230 #define res_queriesmatch __res_queriesmatch
231
232 __BEGIN_DECLS
233
234 W32_FUNC int      __res_hnok   (const char *);
235 W32_FUNC int      __res_ownok  (const char *);
236 W32_FUNC int      __res_mailok (const char *);
237 W32_FUNC int      __res_dnok   (const char *);
238 W32_FUNC int      __loc_aton   (const char *ascii, u_char *binary);
239 W32_FUNC char *   __loc_ntoa   (const u_char *binary, char *ascii);
240 W32_FUNC int      __dn_skipname(const u_char *, const u_char *);
241 W32_FUNC void     __fp_resstat (struct __res_state *, FILE *);
242 W32_FUNC void     __fp_query   (const u_char *, FILE *);
243 W32_FUNC void     __fp_nquery  (const u_char *, int, FILE *);
244 W32_FUNC char    *__hostalias  (const char *);
245 W32_FUNC void     __putlong    (u_long,  u_char *);
246 W32_FUNC void     __putshort   (u_short, u_char *);
247 W32_FUNC char    *__p_time     (u_long);
248 W32_FUNC void     __p_query    (const u_char *);
249
250 W32_FUNC const u_char *__p_cdnname (const u_char *, const u_char *, int, FILE *);
251 W32_FUNC const u_char *__p_cdname  (const u_char *, const u_char *, FILE *);
252 W32_FUNC const u_char *__p_fqname  (const u_char *, const u_char *, FILE *);
253 W32_FUNC const u_char *__p_rr      (const u_char *, const u_char *, FILE *);
254 W32_FUNC const char   *__p_type    (int);
255 W32_FUNC const char   *__p_class   (int);
256 W32_FUNC const char   *__p_option  (u_long option);
257
258 W32_FUNC int     dn_comp   (const char *, u_char *, int, u_char **, u_char **);
259 W32_FUNC int     dn_expand (const u_char *, const u_char *, const u_char *, char *, int);
260
261 W32_FUNC int     res_init        (void);
262 W32_FUNC u_short res_randomid    (void);
263 W32_FUNC int     res_query       (const char *, int, int, u_char *, int);
264 W32_FUNC int     res_search      (const char *, int, int, u_char *, int);
265 W32_FUNC int     res_querydomain (const char *, const char *, int, int, u_char *, int);
266 W32_FUNC int     res_mkquery     (int, const char *, int, int, const u_char *, int, const u_char *, u_char *, int);
267 W32_FUNC int     res_send        (const u_char *, int, u_char *, int);
268 W32_FUNC int     res_isourserver (const struct sockaddr_in *);
269 W32_FUNC int     res_nameinquery (const char *, int, int, const u_char *, const u_char *);
270 W32_FUNC int     res_queriesmatch(const u_char *, const u_char *, const u_char *, const u_char *);
271
272 W32_FUNC void    res_send_setqhook (res_send_qhook hook);
273 W32_FUNC void    res_send_setrhook (res_send_rhook hook);
274
275 __END_DECLS
276
277 #endif /* !_RESOLV_H_ */