Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / dhcp / includes / minires / resolv.h
blob76b0149a097662f96e496138021683d0cc1b33b3
1 /*
2 * Copyright (c) 1983, 1987, 1989
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
31 * Portions Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
32 * Portions Copyright (c) 1995-2003 by Internet Software Consortium
34 * Permission to use, copy, modify, and distribute this software for any
35 * purpose with or without fee is hereby granted, provided that the above
36 * copyright notice and this permission notice appear in all copies.
38 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
39 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
40 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
41 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
42 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
43 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
44 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
46 * Internet Systems Consortium, Inc.
47 * 950 Charter Street
48 * Redwood City, CA 94063
49 * <info@isc.org>
50 * http://www.isc.org/
54 * @(#)resolv.h 8.1 (Berkeley) 6/2/93
55 * $Id: resolv.h,v 1.3 2005/08/11 17:13:26 drochner Exp $
58 #ifndef _RESOLV_H_
59 #define _RESOLV_H_
62 * This used to be defined in res_query.c, now it's in herror.c.
63 * [XXX no it's not. It's in irs/irs_data.c]
64 * It was
65 * never extern'd by any *.h file before it was placed here. For thread
66 * aware programs, the last h_errno value set is stored in res->h_errno.
68 * XXX: There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO
69 * (and __h_errno_set) to the public via <resolv.h>.
70 * XXX: __h_errno_set is really part of IRS, not part of the resolver.
71 * If somebody wants to build and use a resolver that doesn't use IRS,
72 * what do they do? Perhaps something like
73 * #ifdef WANT_IRS
74 * # define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
75 * #else
76 * # define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x))
77 * #endif
80 #define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
81 struct __res_state; /* forward */
82 void __h_errno_set(struct __res_state *res, int err);
85 * Resolver configuration file.
86 * Normally not present, but may contain the address of the
87 * inital name server(s) to query and the domain search list.
90 #ifndef _PATH_RESCONF
91 #define _PATH_RESCONF "/etc/resolv.conf"
92 #endif
94 typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
95 res_sendhookact;
97 typedef res_sendhookact (*res_send_qhook) (struct sockaddr_in * const *ns,
98 double **query,
99 unsigned *querylen,
100 double *ans,
101 unsigned anssiz,
102 int *resplen);
104 typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *ns,
105 double *query,
106 unsigned querylen,
107 double *ans,
108 unsigned anssiz,
109 int *resplen);
111 struct res_sym {
112 int number; /* Identifying number, like T_MX */
113 char * name; /* Its symbolic name, like "MX" */
114 char * humanname; /* Its fun name, like "mail exchanger" */
118 * Global defines and variables for resolver stub.
120 #define MAXNS 3 /* max # name servers we'll track */
121 #define MAXDFLSRCH 3 /* # default domain levels to try */
122 #define MAXDNSRCH 6 /* max # domains in search path */
123 #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
125 #define RES_TIMEOUT 5 /* min. seconds between retries */
126 #define MAXRESOLVSORT 10 /* number of net to sort on */
127 #define RES_MAXNDOTS 15 /* should reflect bit field size */
128 #define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
129 #define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
130 #define RES_DFLRETRY 2 /* Default #/tries. */
132 struct __res_state {
133 int retrans; /* retransmition time interval */
134 int retry; /* number of times to retransmit */
135 u_long options; /* option flags - see below. */
136 int nscount; /* number of name servers */
137 struct sockaddr_in
138 nsaddr_list[MAXNS]; /* address of name server */
139 #define nsaddr nsaddr_list[0] /* for backward compatibility */
140 u_short id; /* current message id */
141 char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
142 char defdname[256]; /* default domain (deprecated) */
143 u_long pfcode; /* RES_PRF_ flags - see below. */
144 unsigned ndots:4; /* threshold for initial abs. query */
145 unsigned nsort:4; /* number of elements in sort_list[] */
146 char unused[3];
147 struct {
148 struct in_addr addr;
149 u_int32_t mask;
150 } sort_list[MAXRESOLVSORT];
151 res_send_qhook qhook; /* query hook */
152 res_send_rhook rhook; /* response hook */
153 int res_h_errno; /* last one set for this context */
154 int _sock; /* PRIVATE: for res_send i/o */
155 u_int _flags; /* PRIVATE: see below */
156 char pad[52]; /* On an i386 this means 512b total. */
159 typedef struct __res_state *res_state;
162 * Resolver flags (used to be discrete per-module statics ints).
164 #define RES_F_VC 0x00000001 /* socket is TCP */
165 #define RES_F_CONN 0x00000002 /* socket is connected */
167 /* res_findzonecut() options */
168 #define RES_EXHAUSTIVE 0x00000001 /* always do all queries */
171 * Resolver options (keep these in synch with res_debug.c, please)
173 #define RES_INIT 0x00000001 /* address initialized */
174 #define RES_DEBUG 0x00000002 /* print debug messages */
175 #define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
176 #define RES_USEVC 0x00000008 /* use virtual circuit */
177 #define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
178 #define RES_IGNTC 0x00000020 /* ignore trucation errors */
179 #define RES_RECURSE 0x00000040 /* recursion desired */
180 #define RES_DEFNAMES 0x00000080 /* use default domain name */
181 #define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
182 #define RES_DNSRCH 0x00000200 /* search up local domain tree */
183 #define RES_INSECURE1 0x00000400 /* type 1 security disabled */
184 #define RES_INSECURE2 0x00000800 /* type 2 security disabled */
185 #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
186 #define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
187 #define RES_ROTATE 0x00004000 /* rotate ns list after each query */
188 #define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
189 #define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
191 #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
194 * Resolver "pfcode" values. Used by dig.
196 #define RES_PRF_STATS 0x00000001
197 #define RES_PRF_UPDATE 0x00000002
198 #define RES_PRF_CLASS 0x00000004
199 #define RES_PRF_CMD 0x00000008
200 #define RES_PRF_QUES 0x00000010
201 #define RES_PRF_ANS 0x00000020
202 #define RES_PRF_AUTH 0x00000040
203 #define RES_PRF_ADD 0x00000080
204 #define RES_PRF_HEAD1 0x00000100
205 #define RES_PRF_HEAD2 0x00000200
206 #define RES_PRF_TTLID 0x00000400
207 #define RES_PRF_HEADX 0x00000800
208 #define RES_PRF_QUERY 0x00001000
209 #define RES_PRF_REPLY 0x00002000
210 #define RES_PRF_INIT 0x00004000
211 /* 0x00008000 */
213 #if 0
214 /* Things involving an internal (static) resolver context. */
215 #ifdef _REENTRANT
216 extern struct __res_state *__res_state(void);
217 #define _res (*__res_state())
218 #else
219 #ifndef __BIND_NOSTATIC
220 extern struct __res_state _res;
221 #endif
222 #endif
224 void fp_nquery (const u_char *, int, FILE *);
225 void fp_query (const u_char *, FILE *);
226 const char * hostalias (const char *);
227 void p_query (const u_char *);
228 void res_close (void);
229 int res_init (void);
230 int res_isourserver (const struct sockaddr_in *);
231 int res_mkquery (int, const char *, int, int, const u_char *,
232 int, const u_char *, u_char *, int);
233 int res_query (const char *, int, int, u_char *, int);
234 int res_querydomain (const char *, const char *, int, int,
235 u_char *, int);
236 int res_search (const char *, int, int, u_char *, int);
237 int res_send (const u_char *, int, u_char *, int);
238 int res_sendsigned (const u_char *, int, ns_tsig_key *,
239 u_char *, int);
241 #if !defined(SHARED_LIBBIND) || defined(LIB)
243 * If libbind is a shared object (well, DLL anyway)
244 * these externs break the linker when resolv.h is
245 * included by a lib client (like named)
246 * Make them go away if a client is including this
249 extern const struct res_sym __p_key_syms[];
250 extern const struct res_sym __p_cert_syms[];
251 extern const struct res_sym __p_class_syms[];
252 extern const struct res_sym __p_type_syms[];
253 extern const struct res_sym __p_rcode_syms[];
254 #endif /* SHARED_LIBBIND */
256 int res_hnok (const char *);
257 int res_ownok (const char *);
258 int res_mailok (const char *);
259 int res_dnok (const char *);
260 int sym_ston (const struct res_sym *, const char *, int *);
261 const char * sym_ntos (const struct res_sym *, int, int *);
262 const char * sym_ntop (const struct res_sym *, int, int *);
263 int b64_ntop (u_char const *, size_t, char *, size_t);
264 int b64_pton (char const *, u_char *, size_t);
265 int loc_aton (const char *ascii, u_char *binary);
266 const char * loc_ntoa (const u_char *binary, char *ascii);
267 int dn_skipname (const u_char *, const u_char *);
268 void putlong (u_int32_t, u_char *);
269 void putshort (u_int16_t, u_char *);
270 const char * p_class (int);
271 const char * p_time (u_int32_t);
272 const char * p_type (int);
273 const char * p_rcode (int);
274 const u_char * p_cdnname (const u_char *, const u_char *, int, FILE *);
275 const u_char * p_cdname (const u_char *, const u_char *, FILE *);
276 const u_char * p_fqnname (const u_char *cp, const u_char *msg,
277 int, char *, int);
278 const u_char * p_fqname (const u_char *, const u_char *, FILE *);
279 const char * p_option (u_long option);
280 char * p_secstodate (u_long);
281 int dn_count_labels (const char *);
282 int dn_expand (const u_char *, const u_char *, const u_char *,
283 char *, int);
284 u_int res_randomid (void);
285 int res_nameinquery (const char *, int, int,
286 const u_char *, const u_char *);
287 int res_queriesmatch (const u_char *, const u_char *,
288 const u_char *, const u_char *);
289 const char * p_section (int section, int opcode);
290 /* Things involving a resolver context. */
291 int res_ninit (res_state);
292 int res_nisourserver (const res_state,
293 const struct sockaddr_in *);
294 void fp_resstat (const res_state, FILE *);
295 void res_npquery (const res_state, const u_char *, int, FILE *);
296 const char * res_hostalias (const res_state, const char *,
297 char *, size_t);
298 int res_nquery (res_state,
299 const char *, int, int, u_char *, int);
300 int res_nsearch (res_state, const char *, int,
301 int, u_char *, int);
302 int res_nquerydomain (res_state,
303 const char *, const char *, int, int,
304 u_char *, int);
305 int res_nmkquery (res_state,
306 int, const char *, int, int, const u_char *,
307 int, const u_char *, u_char *, int);
308 int res_nsend (res_state, const u_char *, int, u_char *, int);
309 int res_nsendsigned (res_state, const u_char *, int,
310 ns_tsig_key *, u_char *, int);
311 int res_findzonecut (res_state, const char *, ns_class, int,
312 char *, size_t, struct in_addr *, int);
313 void res_nclose (res_state);
315 #endif /* 0 */
316 #endif /* !_RESOLV_H_ */