xref: /haiku/src/system/libnetwork/netresolv/include/resolv.h (revision e1c4049fed1047bdb957b0529e1921e97ef94770)
1 /*! This file includes only the portions of <resolv.h> not present in the public headers. */
2 /*
3  * Portions Copyright (C) 2004, 2005, 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
4  * Portions Copyright (C) 1995-2003  Internet Software Consortium.
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * Copyright (c) 1983, 1987, 1989
21  *    The Regents of the University of California.  All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the above copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. Neither the name of the University nor the names of its contributors
32  *    may be used to endorse or promote products derived from this software
33  *    without specific prior written permission.
34  *
35  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
36  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45  * SUCH DAMAGE.
46  */
47 
48 #ifndef _RESOLV_H_
49 #include_next <resolv.h>
50 
51 #include <sys/cdefs.h>
52 
53 #define	nsaddr	nsaddr_list[0]		/*%< for backward compatibility */
54 
55 /*%
56  * This used to be defined in res_query.c, now it's in herror.c.
57  * [XXX no it's not.  It's in irs/irs_data.c]
58  * It was
59  * never extern'd by any *.h file before it was placed here.  For thread
60  * aware programs, the last h_errno value set is stored in res->h_errno.
61  *
62  * XXX:	There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO
63  *	(and __h_errno_set) to the public via <resolv.h>.
64  * XXX:	__h_errno_set is really part of IRS, not part of the resolver.
65  *	If somebody wants to build and use a resolver that doesn't use IRS,
66  *	what do they do?  Perhaps something like
67  *		#ifdef WANT_IRS
68  *		# define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
69  *		#else
70  *		# define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x))
71  *		#endif
72  */
73 
74 #define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
75 struct __res_state; /*%< forward */
76 __BEGIN_DECLS
77 void __h_errno_set(struct __res_state *, int);
78 __END_DECLS
79 
80 typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
81 	res_sendhookact;
82 
83 typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *,
84 						  const u_char **, int *,
85 						  u_char *, int, int *);
86 
87 typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *,
88 						  const u_char *, int, u_char *,
89 						  int, int *);
90 
91 union res_sockaddr_union {
92 	struct sockaddr_in	sin;
93 #ifdef IN6ADDR_ANY_INIT
94 	struct sockaddr_in6	sin6;
95 #endif
96 #ifdef ISC_ALIGN64
97 	int64_t			__align64;	/*%< 64bit alignment */
98 #else
99 	int32_t			__align32;	/*%< 32bit alignment */
100 #endif
101 	char			__space[128];   /* max size */
102 };
103 
104 /*%
105  * Resolver flags (used to be discrete per-module statics ints).
106  */
107 #define	RES_F__UNUSED	0x00000008	/*%< (unused) */
108 #define	RES_F_LASTMASK	0x000000F0	/*%< ordinal server of last res_nsend */
109 #define	RES_F_LASTSHIFT	4		/*%< bit position of LASTMASK "flag" */
110 #define	RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
111 
112 /*%
113  * Resolver options (keep these in synch with res_debug.c, please)
114  */
115 #define RES_NSID		(1 << 18)   /*%< request name server ID */
116 /* KAME extensions: use higher bit to avoid conflict with ISC use */
117 #define RES_USE_DNAME	0x10000000	/*%< use DNAME */
118 
119 /* Things involving an internal (static) resolver context. */
120 __BEGIN_DECLS
121 extern struct __res_state *__res_get_state(void);
122 extern void __res_put_state(struct __res_state *);
123 
124 /*
125  * Source and Binary compatibility; _res will not work properly
126  * with multi-threaded programs.
127  */
128 __END_DECLS
129 
130 #ifndef __BIND_NOSTATIC
131 #define	res_opt			__res_opt
132 #define res_sendsigned		__res_sendsigned
133 
134 __BEGIN_DECLS
135 int		res_opt(int, u_char *, int, int);
136 int		res_sendsigned(const u_char *, int, ns_tsig_key *,
137 					u_char *, int);
138 __END_DECLS
139 #endif
140 
141 #if !defined(SHARED_LIBBIND) || defined(LIB)
142 /*
143  * If libbind is a shared object (well, DLL anyway)
144  * these externs break the linker when resolv.h is
145  * included by a lib client (like named)
146  * Make them go away if a client is including this
147  *
148  */
149 extern const struct res_sym __p_key_syms[];
150 extern const struct res_sym __p_cert_syms[];
151 extern const struct res_sym __p_class_syms[];
152 extern const struct res_sym __p_type_syms[];
153 extern const struct res_sym __p_rcode_syms[];
154 #endif /* SHARED_LIBBIND */
155 
156 
157 #define p_secstodate		__p_secstodate
158 #define p_section		__p_section
159 #define p_sockun		__p_sockun
160 #define putlong			__putlong
161 #define putshort		__putshort
162 #define	res_check		__res_check
163 #define res_findzonecut		__res_findzonecut
164 #define res_findzonecut2	__res_findzonecut2
165 #define res_pquery		__res_pquery
166 #define res_nsendsigned		__res_nsendsigned
167 #define res_nisourserver	__res_nisourserver
168 #define res_rndinit		__res_rndinit
169 #define res_nrandomid		__res_nrandomid
170 #define res_nopt		__res_nopt
171 #define res_nopt_rdata       	__res_nopt_rdata
172 #define res_ndestroy		__res_ndestroy
173 #define	res_nametoclass		__res_nametoclass
174 #define	res_nametotype		__res_nametotype
175 #define	res_setservers		__res_setservers
176 #define	res_getservers		__res_getservers
177 #define	res_buildprotolist	__res_buildprotolist
178 #define	res_destroyprotolist	__res_destroyprotolist
179 #define	res_destroyservicelist	__res_destroyservicelist
180 #define	res_get_nibblesuffix	__res_get_nibblesuffix
181 #define	res_get_nibblesuffix2	__res_get_nibblesuffix2
182 #define	res_ourserver_p		__res_ourserver_p
183 #define	res_send_setqhook	__res_send_setqhook
184 #define	res_send_setrhook	__res_send_setrhook
185 #define	res_servicename		__res_servicename
186 #define	res_servicenumber	__res_servicenumber
187 
188 __BEGIN_DECLS
189 struct timespec;
190 int		res_check(res_state, struct timespec *);
191 void		putlong(uint32_t, u_char *);
192 void		putshort(uint16_t, u_char *);
193 #ifndef __ultrix__
194 uint16_t	_getshort(const u_char *);
195 uint32_t	_getlong(const u_char *);
196 #endif
197 const char *	p_sockun(union res_sockaddr_union, char *, size_t);
198 char *		p_secstodate(u_long);
199 void		res_rndinit(res_state);
200 u_int		res_nrandomid(res_state);
201 const char *	p_section(int, int);
202 /* Things involving a resolver context. */
203 void		res_pquery(const res_state, const u_char *, int, FILE *);
204 int		res_nisourserver(const res_state, const struct sockaddr_in *);
205 int		res_nsendsigned(res_state, const u_char *, int,
206 					 ns_tsig_key *, u_char *, int);
207 int		res_findzonecut(res_state, const char *, ns_class, int,
208 					 char *, size_t, struct in_addr *, int);
209 int		res_findzonecut2(res_state, const char *, ns_class, int,
210 					  char *, size_t,
211 					  union res_sockaddr_union *, int);
212 int		res_nopt(res_state, int, u_char *, int, int);
213 int		res_nopt_rdata(res_state, int, u_char *, int, u_char *,
214 					u_short, u_short, u_char *);
215 void		res_send_setqhook(res_send_qhook);
216 void		res_send_setrhook(res_send_rhook);
217 int		__res_vinit(res_state, int);
218 void		res_destroyservicelist(void);
219 const char *	res_servicename(uint16_t, const char *);
220 void		res_destroyprotolist(void);
221 void		res_buildprotolist(void);
222 const char *	res_get_nibblesuffix(res_state);
223 const char *	res_get_nibblesuffix2(res_state);
224 void		res_ndestroy(res_state);
225 uint16_t	res_nametoclass(const char *, int *);
226 uint16_t	res_nametotype(const char *, int *);
227 void		res_setservers(res_state,
228 					const union res_sockaddr_union *, int);
229 int		res_getservers(res_state,
230 					union res_sockaddr_union *, int);
231 __END_DECLS
232 
233 #endif /* !_RESOLV_H_ */
234