1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Common code and structures used by name-service-switch "dns" backends.
29  */
30 
31 #ifndef _DNS_COMMON_H
32 #define	_DNS_COMMON_H
33 
34 #include <stdio.h>
35 #include <ctype.h>
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <netinet/in.h>
39 #include <netdb.h>
40 #include <strings.h>
41 #include <thread.h>
42 #include <arpa/inet.h>
43 #include <arpa/nameser.h>
44 #include <resolv.h>
45 #include <syslog.h>
46 #include <nsswitch.h>
47 #include <nss_common.h>
48 #include <nss_dbdefs.h>
49 #include <stdlib.h>
50 #include <signal.h>
51 
52 #ifdef	__cplusplus
53 extern "C" {
54 #endif
55 
56 typedef struct dns_backend *dns_backend_ptr_t;
57 typedef nss_status_t (*dns_backend_op_t)(dns_backend_ptr_t, void *);
58 
59 struct dns_backend {
60 	dns_backend_op_t	*ops;
61 	nss_dbop_t		n_ops;
62 };
63 
64 /* multithreaded libresolv2 related functions and variables */
65 extern void	(*set_no_hosts_fallback)(void);
66 extern void	(*unset_no_hosts_fallback)(void);
67 extern struct __res_state	*(*set_res_retry)();
68 extern int	(*enable_mt)();
69 extern int	(*disable_mt)();
70 extern int	*(*get_h_errno)();
71 extern int	(*override_retry)(int);
72 extern void	switch_resolver_setup(int *, sigset_t *, int *);
73 extern void	switch_resolver_reset(int, sigset_t, int);
74 extern mutex_t	one_lane;
75 
76 extern int ent2result(struct hostent *, nss_XbyY_args_t *, int);
77 extern int ent2str(struct hostent *, nss_XbyY_args_t *, int);
78 
79 nss_backend_t *_nss_dns_constr(dns_backend_op_t *, int);
80 extern	nss_status_t _herrno2nss(int);
81 
82 nss_status_t _nss_dns_gethost_withttl(void *buf, size_t bufsize, int ipnode);
83 nss_status_t _nss_get_dns_hosts_name(dns_backend_ptr_t *, void **, size_t *);
84 nss_status_t _nss_get_dns_ipnodes_name(dns_backend_ptr_t *, void **, size_t *);
85 
86 #ifdef	__cplusplus
87 }
88 #endif
89 
90 #endif /* _DNS_COMMON_H */
91