xref: /illumos-gate/usr/src/lib/libc/inc/nsswitch_priv.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 #include <nsswitch.h>
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 
48 #define	__NSW_STD_ERRS_V1	5 /* V1 number of reserved errors */
49 
50 /*
51  * Results: the first of which are from /usr/include/nsswitch.h
52  *
53  * #define	__NSW_SUCCESS	0	 found the required data
54  * #define	__NSW_NOTFOUND	1 the naming service returned lookup failure
55  * #define	__NSW_UNAVAIL	2	 could not call the naming service
56  * #define	__NSW_TRYAGAIN	3	 bind error to suggest a retry
57  */
58 
59 /* nis server in dns forwarding mode and dns server non-response */
60 #define	__NSW_NISSERVDNS_TRYAGAIN	4
61 
62 /*
63  * Actions: the first of which are from /usr/include/nsswitch.h
64  *
65  * #define	__NSW_CONTINUE	0 the action is to continue to next service
66  * #define	__NSW_RETURN	1 the action is to return to the user
67  */
68 
69 /* the action is to retry the request until we get an answer */
70 #define	__NSW_TRYAGAIN_FOREVER	2
71 /* the action is to retry the request N times maximum */
72 #define	__NSW_TRYAGAIN_NTIMES	3
73 /* retried N times so disable try-again until service is restored */
74 #define	__NSW_TRYAGAIN_PAUSED	4
75 
76 /* is this action available to all switch errs? */
77 #define	__NSW_COMMON_ACTION(act)\
78 	(((act) == __NSW_CONTINUE) || ((act) == __NSW_RETURN))
79 
80 #define	__NSW_SUCCESS_ACTION(act)	__NSW_COMMON_ACTION(act)
81 #define	__NSW_NOTFOUND_ACTION(act)	__NSW_COMMON_ACTION(act)
82 #define	__NSW_UNAVAIL_ACTION(act)	__NSW_COMMON_ACTION(act)
83 #define	__NSW_TRYAGAIN_ACTION(act) \
84 	(__NSW_COMMON_ACTION(act) || \
85 	    ((act) == __NSW_TRYAGAIN_FOREVER) || \
86 	    ((act) == __NSW_TRYAGAIN_NTIMES))
87 #define	__NSW_UNPAUSE_ACTION(act)\
88 	(((act) == __NSW_TRYAGAIN_PAUSED) && ((act) = __NSW_TRYAGAIN_NTIMES))
89 
90 #define	__NSW_STR_FOREVER	"forever"
91 
92 #ifdef __NSS_PRIVATE_INTERFACE
93 
94 struct __nsw_lookup_v1 {
95 	char *service_name;
96 	action_t actions[__NSW_STD_ERRS_V1];
97 	int max_retries;  /* for TRYAGAIN=N */
98 	struct __nsw_long_err *long_errs;
99 	struct __nsw_lookup_v1 *next;
100 };
101 
102 struct __nsw_switchconfig_v1 {
103 	int vers;
104 	char *dbase;
105 	int num_lookups;
106 	struct __nsw_lookup_v1 *lookups;
107 };
108 
109 #define	__NSW_ACTION_V1(lkp, err) 	\
110 	((lkp)->next == NULL ? \
111 		__NSW_RETURN \
112 	: \
113 		((err) >= 0 && (err) < __NSW_STD_ERRS_V1 ? \
114 			(lkp)->actions[err] \
115 		: \
116 			__nsw_extended_action_v1(lkp, err)))
117 
118 
119 struct __nsw_switchconfig_v1 *__nsw_getconfig_v1
120 	(const char *, enum __nsw_parse_err *);
121 int __nsw_freeconfig_v1(struct __nsw_switchconfig_v1 *);
122 action_t __nsw_extended_action_v1(struct __nsw_lookup_v1 *, int);
123 
124 #endif /* __NSS_PRIVATE_INTERFACE */
125 
126 #ifdef	__cplusplus
127 }
128 #endif
129 
130 #endif /* _NSSWITCH_PRIV_H */
131