xref: /titanic_52/usr/src/lib/libc/inc/nsswitch_priv.h (revision 18c2aff776a775d34a4c9893a4c72e0434d68e36)
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  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * nsswitch_priv.h
28  *
29  * The original switch low level interface to switch was defined in
30  * /usr/include/nsswitch.h.  Although it was marked "Project Private",
31  * it was none-the-less "exposed" and used by several apps.  This
32  * file, nsswitch_priv.h will *not* go in /usr/include to limit "exposure"
33  * and contains new versions of the switch low level interface.
34  *
35  * This is a Project Private interface.  It may change in future releases.
36  */
37 
38 #ifndef _NSSWITCH_PRIV_H
39 #define	_NSSWITCH_PRIV_H
40 
41 #pragma ident	"%Z%%M%	%I%	%E% SMI"
42 
43 #include <nsswitch.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 
50 #define	__NSW_STD_ERRS_V1	5 /* V1 number of reserved errors */
51 
52 /*
53  * Results: the first of which are from /usr/include/nsswitch.h
54  *
55  * #define	__NSW_SUCCESS	0	 found the required data
56  * #define	__NSW_NOTFOUND	1 the naming service returned lookup failure
57  * #define	__NSW_UNAVAIL	2	 could not call the naming service
58  * #define	__NSW_TRYAGAIN	3	 bind error to suggest a retry
59  */
60 
61 /* nis server in dns forwarding mode and dns server non-response */
62 #define	__NSW_NISSERVDNS_TRYAGAIN	4
63 
64 /*
65  * Actions: the first of which are from /usr/include/nsswitch.h
66  *
67  * #define	__NSW_CONTINUE	0 the action is to continue to next service
68  * #define	__NSW_RETURN	1 the action is to return to the user
69  */
70 
71 /* the action is to retry the request until we get an answer */
72 #define	__NSW_TRYAGAIN_FOREVER	2
73 /* the action is to retry the request N times maximum */
74 #define	__NSW_TRYAGAIN_NTIMES	3
75 /* retried N times so disable try-again until service is restored */
76 #define	__NSW_TRYAGAIN_PAUSED	4
77 
78 /* is this action available to all switch errs? */
79 #define	__NSW_COMMON_ACTION(act)\
80 	(((act) == __NSW_CONTINUE) || ((act) == __NSW_RETURN))
81 
82 #define	__NSW_SUCCESS_ACTION(act)	__NSW_COMMON_ACTION(act)
83 #define	__NSW_NOTFOUND_ACTION(act)	__NSW_COMMON_ACTION(act)
84 #define	__NSW_UNAVAIL_ACTION(act)	__NSW_COMMON_ACTION(act)
85 #define	__NSW_TRYAGAIN_ACTION(act) \
86 	(__NSW_COMMON_ACTION(act) || \
87 	    ((act) == __NSW_TRYAGAIN_FOREVER) || \
88 	    ((act) == __NSW_TRYAGAIN_NTIMES))
89 #define	__NSW_UNPAUSE_ACTION(act)\
90 	(((act) == __NSW_TRYAGAIN_PAUSED) && ((act) = __NSW_TRYAGAIN_NTIMES))
91 
92 #define	__NSW_STR_FOREVER	"forever"
93 
94 #ifdef __NSS_PRIVATE_INTERFACE
95 
96 struct __nsw_lookup_v1 {
97 	char *service_name;
98 	action_t actions[__NSW_STD_ERRS_V1];
99 	int max_retries;  /* for TRYAGAIN=N */
100 	struct __nsw_long_err *long_errs;
101 	struct __nsw_lookup_v1 *next;
102 };
103 
104 struct __nsw_switchconfig_v1 {
105 	int vers;
106 	char *dbase;
107 	int num_lookups;
108 	struct __nsw_lookup_v1 *lookups;
109 };
110 
111 #define	__NSW_ACTION_V1(lkp, err) 	\
112 	((lkp)->next == NULL ? \
113 		__NSW_RETURN \
114 	: \
115 		((err) >= 0 && (err) < __NSW_STD_ERRS_V1 ? \
116 			(lkp)->actions[err] \
117 		: \
118 			__nsw_extended_action_v1(lkp, err)))
119 
120 
121 struct __nsw_switchconfig_v1 *__nsw_getconfig_v1
122 	(const char *, enum __nsw_parse_err *);
123 int __nsw_freeconfig_v1(struct __nsw_switchconfig_v1 *);
124 action_t __nsw_extended_action_v1(struct __nsw_lookup_v1 *, int);
125 
126 #endif /* __NSS_PRIVATE_INTERFACE */
127 
128 #ifdef	__cplusplus
129 }
130 #endif
131 
132 #endif /* _NSSWITCH_PRIV_H */
133