1 /*
2  * Copyright 2005 Niels Provos <provos@citi.umich.edu>
3  * 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 Niels Provos.
16  * 4. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 /*	$OpenBSD: netdb.h,v 1.23 2004/12/20 22:35:32 millert Exp $	*/
32 
33 /*
34  * ++Copyright++ 1980, 1983, 1988, 1993
35  * -
36  * Copyright (c) 1980, 1983, 1988, 1993
37  *	The Regents of the University of California.  All rights reserved.
38  *
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  * 1. Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  * 2. Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in the
46  *    documentation and/or other materials provided with the distribution.
47  * 3. Neither the name of the University nor the names of its contributors
48  *    may be used to endorse or promote products derived from this software
49  *    without specific prior written permission.
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61  * SUCH DAMAGE.
62  * -
63  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
64  *
65  * Permission to use, copy, modify, and distribute this software for any
66  * purpose with or without fee is hereby granted, provided that the above
67  * copyright notice and this permission notice appear in all copies, and that
68  * the name of Digital Equipment Corporation not be used in advertising or
69  * publicity pertaining to distribution of the document or software without
70  * specific, written prior permission.
71  *
72  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
73  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
74  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
75  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
76  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
77  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
78  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
79  * SOFTWARE.
80  * -
81  * --Copyright--
82  */
83 
84 /*
85  * Copyright (c) 1995, 1996, 1997, 1998, 1999 Craig Metz. All rights reserved.
86  *
87  * Redistribution and use in source and binary forms, with or without
88  * modification, are permitted provided that the following conditions
89  * are met:
90  * 1. Redistributions of source code must retain the above copyright
91  *    notice, this list of conditions and the following disclaimer.
92  * 2. Redistributions in binary form must reproduce the above copyright
93  *    notice, this list of conditions and the following disclaimer in the
94  *    documentation and/or other materials provided with the distribution.
95  * 3. Neither the name of the author nor the names of any contributors
96  *    may be used to endorse or promote products derived from this software
97  *    without specific prior written permission.
98  *
99  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
100  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
101  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
102  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
103  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
104  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
105  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
106  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
107  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
108  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
109  * SUCH DAMAGE.
110  */
111 
112 /*
113  *      @(#)netdb.h	8.1 (Berkeley) 6/2/93
114  *	$From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $
115  */
116 
117 #ifndef _DNSRES_H_
118 #define _DNSRES_H_
119 
120 #include <sys/param.h>
121 #if (!defined(BSD)) || (BSD < 199306)
122 # include <sys/bitypes.h>
123 #endif
124 #include <sys/cdefs.h>
125 
126 /*
127  * Type values for resources and queries
128  */
129 #define DNSRES_T_A	1	/* host address */
130 #define DNSRES_T_NS	2	/* authoritative server */
131 #define DNSRES_T_MD	3	/* mail destination */
132 #define DNSRES_T_MF	4	/* mail forwarder */
133 #define DNSRES_T_CNAME	5	/* canonical name */
134 #define DNSRES_T_SOA	6	/* start of authority zone */
135 #define DNSRES_T_MB	7	/* mailbox domain name */
136 #define DNSRES_T_MG	8	/* mail group member */
137 #define DNSRES_T_MR	9	/* mail rename name */
138 #define DNSRES_T_NULL	10	/* null resource record */
139 #define DNSRES_T_WKS	11	/* well known service */
140 #define DNSRES_T_PTR	12	/* domain name pointer */
141 #define DNSRES_T_HINFO	13	/* host information */
142 #define DNSRES_T_MINFO	14	/* mailbox information */
143 #define DNSRES_T_MX	15	/* mail routing information */
144 #define DNSRES_T_TXT	16	/* text strings */
145 #define DNSRES_T_RP	17	/* responsible person */
146 #define DNSRES_T_AFSDB	18	/* AFS cell database */
147 #define DNSRES_T_X25	19	/* X_25 calling address */
148 #define DNSRES_T_ISDN	20	/* ISDN calling address */
149 #define DNSRES_T_RT	21	/* router */
150 #define DNSRES_T_NSAP	22	/* NSAP address */
151 #define DNSRES_T_NSAP_PTR	23	/* reverse NSAP lookup (deprecated) */
152 #define DNSRES_T_SIG	24	/* security signature */
153 #define DNSRES_T_KEY	25	/* security key */
154 #define DNSRES_T_PX	26	/* X.400 mail mapping */
155 #define DNSRES_T_GPOS	27	/* geographical position (withdrawn) */
156 #define DNSRES_T_AAAA	28	/* IP6 Address */
157 #define DNSRES_T_LOC	29	/* Location Information */
158 #define DNSRES_T_NXT	30	/* Next Valid Name in Zone */
159 #define DNSRES_T_EID	31	/* Endpoint identifier */
160 #define DNSRES_T_NIMLOC	32	/* Nimrod locator */
161 #define DNSRES_T_SRV	33	/* Server selection */
162 #define DNSRES_T_ATMA	34	/* ATM Address */
163 #define DNSRES_T_NAPTR	35	/* Naming Authority PoinTeR */
164 #define DNSRES_T_KX	36	/* Key Exchanger */
165 #define DNSRES_T_CERT	37	/* CERT */
166 #define DNSRES_T_A6	38	/* A6 */
167 #define DNSRES_T_DNAME	39	/* DNAME */
168 #define DNSRES_T_SINK	40	/* SINK */
169 #define DNSRES_T_OPT	41	/* OPT pseudo-RR, RFC2671 */
170 #define DNSRES_T_APL	42	/* APL */
171 #define DNSRES_T_DS	43	/* Delegation Signer */
172 #define DNSRES_T_SSHFP	44	/* SSH Key Fingerprint */
173 #define DNSRES_T_RRSIG	46	/* RRSIG */
174 #define DNSRES_T_NSEC	47	/* NSEC */
175 #define DNSRES_T_DNSKEY	48	/* DNSKEY */
176 	/* non standard */
177 #define DNSRES_T_UINFO	100	/* user (finger) information */
178 #define DNSRES_T_UID	101	/* user ID */
179 #define DNSRES_T_GID	102	/* group ID */
180 #define DNSRES_T_UNSPEC	103	/* Unspecified format (binary data) */
181 	/* Query type values which do not appear in resource records */
182 #define DNSRES_T_TKEY	249	/* Transaction Key */
183 #define DNSRES_T_TSIG	250	/* Transaction Signature */
184 #define DNSRES_T_IXFR	251	/* incremental zone transfer */
185 #define DNSRES_T_AXFR	252	/* transfer zone of authority */
186 #define DNSRES_T_MAILB	253	/* transfer mailbox records */
187 #define DNSRES_T_MAILA	254	/* transfer mail agent records */
188 #define DNSRES_T_ANY	255	/* wildcard match */
189 
190 /*
191  * Internet nameserver port number
192  */
193 #define DNSRES_NAMESERVER_PORT	53
194 
195 /*
196  * Currently defined opcodes
197  */
198 #define DNSRES_QUERY		0x0	/* standard query */
199 #define DNSRES_IQUERY		0x1	/* inverse query */
200 #define DNSRES_STATUS		0x2	/* nameserver status query */
201 /*#define xxx			0x3*/	/* 0x3 reserved */
202 #define DNSRES_NS_NOTIFY_OP	0x4	/* notify secondary of SOA change */
203 /*
204  * Currently defined response codes
205  */
206 #define DNSRES_NOERROR		0		/* no error */
207 #define DNSRES_FORMERR		1		/* format error */
208 #define DNSRES_SERVFAIL		2		/* server failure */
209 #define DNSRES_NXDOMAIN		3		/* non existent domain */
210 #define DNSRES_NOTIMP		4		/* not implemented */
211 #define DNSRES_REFUSED		5		/* query refused */
212 
213 /*
214  * Values for class field
215  */
216 
217 #define DNSRES_C_IN		1	/* the arpa internet */
218 #define DNSRES_C_CHAOS		3	/* for chaos net (MIT) */
219 #define DNSRES_C_HS		4	/* for Hesiod name server (MIT)(XXX) */
220 	/* Query class values which do not appear in resource records */
221 #define DNSRES_C_ANY		255	/* wildcard match */
222 
223 /*
224  * EDNS0 Z-field extended flags
225  */
226 #define DNSRES_MESSAGEEXTFLAG_DO   0x8000U
227 
228 #define	DNSRES_PATH_HEQUIV	"/etc/hosts.equiv"
229 #define	DNSRES_PATH_HOSTS	"/etc/hosts"
230 #define	DNSRES_PATH_NETWORKS	"/etc/networks"
231 #define	DNSRES_PATH_PROTOCOLS	"/etc/protocols"
232 #define	DNSRES_PATH_SERVICES	"/etc/services"
233 
234 /*
235  * Structures returned by network data base library.  All addresses are
236  * supplied in host order, and returned in network order (suitable for
237  * use in system calls).
238  */
239 struct	dnsres_hostent {
240 	char	*h_name;	/* official name of host */
241 	char	**h_aliases;	/* alias list */
242 	int	h_addrtype;	/* host address type */
243 	int	h_length;	/* length of address */
244 	char	**h_addr_list;	/* list of addresses from name server */
245 };
246 
247 /*
248  * Assumption here is that a network number
249  * fits in an in_addr_t -- probably a poor one.
250  */
251 struct	dnsres_netent {
252 	char		*n_name;	/* official name of net */
253 	char		**n_aliases;	/* alias list */
254 	int		n_addrtype;	/* net address type */
255 	in_addr_t	n_net;		/* network # */
256 };
257 
258 struct	dnsres_servent {
259 	char	*s_name;	/* official service name */
260 	char	**s_aliases;	/* alias list */
261 	int	s_port;		/* port # */
262 	char	*s_proto;	/* protocol to use */
263 };
264 
265 struct	dnsres_protoent {
266 	char	*p_name;	/* official protocol name */
267 	char	**p_aliases;	/* alias list */
268 	int	p_proto;	/* protocol # */
269 };
270 
271 /*
272  * Error return codes from gethostbyname() and gethostbyaddr()
273  * (left in extern int dr_errno).
274  */
275 
276 #define	DNSRES_NETDB_INTERNAL	-1	/* see errno */
277 #define	DNSRES_NETDB_SUCCESS	0	/* no problem */
278 #define	DNSRES_HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
279 #define	DNSRES_TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
280 #define	DNSRES_NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
281 #define	DNSRES_NO_DATA		4 /* Valid name, no data record of requested type */
282 #define	DNSRES_NO_ADDRESS	DNSRES_NO_DATA	/* no address, look for MX record */
283 
284 /* Values for getaddrinfo() and getnameinfo() */
285 #define DNSRES_AI_PASSIVE	1	/* socket address is intended for bind() */
286 #define DNSRES_AI_CANONNAME	2	/* request for canonical name */
287 #define DNSRES_AI_NUMERICHOST	4	/* don't ever try hostname lookup */
288 #define DNSRES_AI_EXT		8	/* enable non-portable extensions */
289 #define DNSRES_AI_NUMERICSERV	16	/* don't ever try servname lookup */
290 /* valid flags for addrinfo */
291 #define DNSRES_AI_MASK \
292     (DNSRES_AI_PASSIVE | DNSRES_AI_CANONNAME | \
293      DNSRES_AI_NUMERICHOST | DNSRES_AI_NUMERICSERV)
294 
295 #define DNSRES_NI_NUMERICHOST	1	/* return the host address, not the name */
296 #define DNSRES_NI_NUMERICSERV	2	/* return the service address, not the name */
297 #define DNSRES_NI_NOFQDN	4	/* return a short name if in the local domain */
298 #define DNSRES_NI_NAMEREQD	8	/* fail if either host or service name is unknown */
299 #define DNSRES_NI_DGRAM	16	/* look up datagram service instead of stream */
300 
301 #define DNSRES_NI_MAXHOST	MAXHOSTNAMELEN	/* max host name returned by getnameinfo */
302 #define DNSRES_NI_MAXSERV	32	/* max serv. name length returned by getnameinfo */
303 
304 /*
305  * Scope delimit character (KAME hack)
306  */
307 #define DNSRES_SCOPE_DELIMITER '%'
308 
309 #define DNSRES_EAI_BADFLAGS	-1	/* invalid value for ai_flags */
310 #define DNSRES_EAI_NONAME	-2	/* name or service is not known */
311 #define DNSRES_EAI_AGAIN	-3	/* temporary failure in name resolution */
312 #define DNSRES_EAI_FAIL	-4	/* non-recoverable failure in name resolution */
313 #define DNSRES_EAI_NODATA	-5	/* no address associated with name */
314 #define DNSRES_EAI_FAMILY	-6	/* ai_family not supported */
315 #define DNSRES_EAI_SOCKTYPE	-7	/* ai_socktype not supported */
316 #define DNSRES_EAI_SERVICE	-8	/* service not supported for ai_socktype */
317 #define DNSRES_EAI_ADDRFAMILY	-9	/* address family for name not supported */
318 #define DNSRES_EAI_MEMORY	-10	/* memory allocation failure */
319 #define DNSRES_EAI_SYSTEM	-11	/* system error (code indicated in errno) */
320 #define DNSRES_EAI_BADHINTS	-12	/* invalid value for hints */
321 #define DNSRES_EAI_PROTOCOL	-13	/* resolved protocol is unknown */
322 
323 /*
324  * Flags for getrrsetbyname()
325  */
326 #define DNSRES_RRSET_VALIDATED		1
327 
328 /*
329  * Return codes for getrrsetbyname()
330  */
331 #define DNSRES_ERRSET_SUCCESS		0
332 #define DNSRES_ERRSET_NOMEMORY		1
333 #define DNSRES_ERRSET_FAIL		2
334 #define DNSRES_ERRSET_INVAL		3
335 #define DNSRES_ERRSET_NONAME		4
336 #define DNSRES_ERRSET_NODATA		5
337 
338 /*
339  * Structures used by getrrsetbyname() and freerrset()
340  */
341 struct dnsres_rdatainfo {
342 	unsigned int		rdi_length;	/* length of data */
343 	unsigned char		*rdi_data;	/* record data */
344 };
345 
346 struct dnsres_rrsetinfo {
347 	unsigned int		rri_flags;	/* RRSET_VALIDATED ... */
348 	unsigned int		rri_rdclass;	/* class number */
349 	unsigned int		rri_rdtype;	/* RR type number */
350 	unsigned int		rri_ttl;	/* time to live */
351 	unsigned int		rri_nrdatas;	/* size of rdatas array */
352 	unsigned int		rri_nsigs;	/* size of sigs array */
353 	char			*rri_name;	/* canonical name */
354 	struct dnsres_rdatainfo	*rri_rdatas;	/* individual records */
355 	struct dnsres_rdatainfo	*rri_sigs;	/* individual signatures */
356 };
357 
358 #ifndef POSIX_SOURCE
359 struct dnsres_servent_data {
360 	void *fp;
361 	char **aliases;
362 	int maxaliases;
363 	int stayopen;
364 	char *line;
365 };
366 
367 struct dnsres_protoent_data {
368 	void *fp;
369 	char **aliases;
370 	int maxaliases;
371 	int stayopen;
372 	char *line;
373 };
374 #endif
375 
376 __BEGIN_DECLS
377 struct addrinfo;
378 struct dnsres;
379 struct dnsres_cbstate;
380 struct dnsres_servent_state;
381 struct dnsres_hostent_state;
382 void		dnsres_endhostent(void);
383 void		dnsres_endnetent(void);
384 void		dnsres_endprotoent(void);
385 void		dnsres_endservent(struct dnsres_servent_state *);
386 void		*dnsres_gethostbyaddr(struct dnsres *_resp,
387 		    const char *addr, int len, int af,
388 		    void (*cb)(struct dnsres_hostent *, int, void *),
389 		    void *arg);
390 void		*dnsres_gethostbyname(struct dnsres *_resp, const char *name,
391 		    void (*cb)(struct dnsres_hostent *, int, void *),
392 		    void *arg);
393 void		*dnsres_gethostbyname2(struct dnsres *_resp, const char *name,
394 		    int af, void (*cb)(struct dnsres_hostent *, int, void *),
395 		    void *arg);
396 struct dnsres_hostent
397 		*dnsres_gethostent(struct dnsres *_resp,
398 		    struct dnsres_cbstate *state);
399 struct dnsres_netent
400 		*dnsres_getnetbyaddr(in_addr_t, int);
401 struct dnsres_netent
402 		*dnsres_getnetbyname(const char *);
403 struct dnsres_netent
404 		*dnsres_getnetent(void);
405 struct dnsres_protoent
406 		*dnsres_getprotobyname(const char *);
407 struct dnsres_protoent
408 		*dnsres_getprotobynumber(int);
409 struct dnsres_protoent
410 		*dnsres_getprotoent(void);
411 struct dnsres_servent
412 		*dnsres_getservbyname(struct dnsres_servent_state *,
413 		    const char *name, const char *proto,
414 		    struct dnsres_servent *se, char *buf, int buflen);
415 struct dnsres_servent
416 		*dnsres_getservbyport(int, const char *);
417 struct dnsres_servent
418 		*dnsres_getservent(struct dnsres_servent_state *);
419 void		dnsres_herror(const char *);
420 const char	*dnsres_hstrerror(int);
421 void		dnsres_sethostent(int);
422 void		dnsres_setnetent(int);
423 void		dnsres_setprotoent(int);
424 void		dnsres_setservent(struct dnsres_servent_state *, int);
425 
426 void		dnsres_getaddrinfo(struct dnsres *, const char *, const char *,
427 		    const struct addrinfo *,
428 		    void (*)(struct addrinfo *, int, void *),
429 		    void *);
430 const char	*dnsres_gai_strerror(int);
431 int		dnsres_net_addrcmp(struct sockaddr *, struct sockaddr *);
432 int		dnsres_getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct dnsres_rrsetinfo **);
433 void		dnsres_freerrset(struct dnsres_rrsetinfo *);
434 int		dnsres_init(struct dnsres *);
435 void		dnsres_cancel_lookup(void *);
436 __END_DECLS
437 
438 /*
439  * Global defines and variables for resolver stub.
440  */
441 
442 #define	MAXNS			3	/* max # name servers we'll track */
443 #define	MAXDFLSRCH		3	/* # default domain levels to try */
444 #define	MAXDNSRCH		6	/* max # domains in search path */
445 #define	LOCALDOMAINPARTS	2	/* min levels in name that is "local" */
446 #define MAXDNSLUS		4	/* max # of host lookup types */
447 
448 #define	RES_TIMEOUT		5	/* min. seconds between retries */
449 #define	MAXRESOLVSORT		10	/* number of net to sort on */
450 #define	RES_MAXNDOTS		15	/* should reflect bit field size */
451 
452 #define	MAXALIASES		35
453 
454 struct dnsres_servent_state {
455 	FILE *servf;
456 	char line[BUFSIZ+1];
457 	struct dnsres_servent serv;
458 	char *serv_aliases[MAXALIASES];
459 	int stayopen;
460 };
461 
462 struct dnsres_hostent_state {
463 	FILE *hostf;
464 	int stayopen;
465 };
466 
467 struct dnsres {
468 	int	retrans;	 	/* retransmission time interval */
469 	int	retry;			/* number of times to retransmit */
470 	unsigned long	options;	/* option flags - see below. */
471 	int	nscount;		/* number of name servers */
472 	struct sockaddr_in
473 		nsaddr_list[MAXNS];	/* address of name server */
474 #define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
475 	unsigned short	id;		/* current message id */
476 	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
477 	char	defdname[256];		/* default domain (deprecated) */
478 	unsigned long	pfcode;		/* RES_PRF_ flags - see below. */
479 	unsigned ndots:4;		/* threshold for initial abs. query */
480 	unsigned nsort:4;		/* number of elements in sort_list[] */
481 	char	unused[3];
482 	struct {
483 		struct in_addr	addr;
484 		u_int32_t	mask;
485 	} sort_list[MAXRESOLVSORT];
486 	char    lookups[MAXDNSLUS];
487 
488 	int dr_errno;				/* keep track of errors */
489 /*
490  * replacement of dnsres, separated to keep binary compatibility.
491  * XXX - niels - included until I grok the code better.
492  */
493 	struct dnsres_ext {
494 		struct sockaddr_storage nsaddr_list[MAXNS];
495 		struct {
496 			int	af;	/* address family for addr, mask */
497 			union {
498 				struct in_addr ina;
499 				struct in6_addr in6a;
500 			} addr, mask;
501 		} sort_list[MAXRESOLVSORT];
502 	} ext;
503 
504 	struct dnsres_hostent_state hostent_state;
505 	struct dnsres_servent_state servent_state;
506 };
507 
508 #endif /* _DNSRES_H_ */
509