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