17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*004388ebScasper  * Common Development and Distribution License (the "License").
6*004388ebScasper  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*004388ebScasper  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * nsswitch_priv.h
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  * The original switch low level interface to switch was defined in
307c478bd9Sstevel@tonic-gate  * /usr/include/nsswitch.h.  Although it was marked "Project Private",
317c478bd9Sstevel@tonic-gate  * it was none-the-less "exposed" and used by several apps.  This
327c478bd9Sstevel@tonic-gate  * file, nsswitch_priv.h will *not* go in /usr/include to limit "exposure"
337c478bd9Sstevel@tonic-gate  * and contains new versions of the switch low level interface.
347c478bd9Sstevel@tonic-gate  *
357c478bd9Sstevel@tonic-gate  * This is a Project Private interface.  It may change in future releases.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifndef _NSSWITCH_PRIV_H
397c478bd9Sstevel@tonic-gate #define	_NSSWITCH_PRIV_H
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <nsswitch.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
447c478bd9Sstevel@tonic-gate extern "C" {
457c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define	__NSW_STD_ERRS_V1	5 /* V1 number of reserved errors */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * Results: the first of which are from /usr/include/nsswitch.h
527c478bd9Sstevel@tonic-gate  *
537c478bd9Sstevel@tonic-gate  * #define	__NSW_SUCCESS	0	 found the required data
547c478bd9Sstevel@tonic-gate  * #define	__NSW_NOTFOUND	1 the naming service returned lookup failure
557c478bd9Sstevel@tonic-gate  * #define	__NSW_UNAVAIL	2	 could not call the naming service
567c478bd9Sstevel@tonic-gate  * #define	__NSW_TRYAGAIN	3	 bind error to suggest a retry
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /* nis server in dns forwarding mode and dns server non-response */
607c478bd9Sstevel@tonic-gate #define	__NSW_NISSERVDNS_TRYAGAIN	4
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Actions: the first of which are from /usr/include/nsswitch.h
647c478bd9Sstevel@tonic-gate  *
657c478bd9Sstevel@tonic-gate  * #define	__NSW_CONTINUE	0 the action is to continue to next service
667c478bd9Sstevel@tonic-gate  * #define	__NSW_RETURN	1 the action is to return to the user
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* the action is to retry the request until we get an answer */
707c478bd9Sstevel@tonic-gate #define	__NSW_TRYAGAIN_FOREVER	2
717c478bd9Sstevel@tonic-gate /* the action is to retry the request N times maximum */
727c478bd9Sstevel@tonic-gate #define	__NSW_TRYAGAIN_NTIMES	3
737c478bd9Sstevel@tonic-gate /* retried N times so disable try-again until service is restored */
747c478bd9Sstevel@tonic-gate #define	__NSW_TRYAGAIN_PAUSED	4
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /* is this action available to all switch errs? */
777c478bd9Sstevel@tonic-gate #define	__NSW_COMMON_ACTION(act)\
787c478bd9Sstevel@tonic-gate 	(((act) == __NSW_CONTINUE) || ((act) == __NSW_RETURN))
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	__NSW_SUCCESS_ACTION(act)	__NSW_COMMON_ACTION(act)
817c478bd9Sstevel@tonic-gate #define	__NSW_NOTFOUND_ACTION(act)	__NSW_COMMON_ACTION(act)
827c478bd9Sstevel@tonic-gate #define	__NSW_UNAVAIL_ACTION(act)	__NSW_COMMON_ACTION(act)
837c478bd9Sstevel@tonic-gate #define	__NSW_TRYAGAIN_ACTION(act) \
847c478bd9Sstevel@tonic-gate 	(__NSW_COMMON_ACTION(act) || \
857c478bd9Sstevel@tonic-gate 	    ((act) == __NSW_TRYAGAIN_FOREVER) || \
867c478bd9Sstevel@tonic-gate 	    ((act) == __NSW_TRYAGAIN_NTIMES))
877c478bd9Sstevel@tonic-gate #define	__NSW_UNPAUSE_ACTION(act)\
887c478bd9Sstevel@tonic-gate 	(((act) == __NSW_TRYAGAIN_PAUSED) && ((act) = __NSW_TRYAGAIN_NTIMES))
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	__NSW_STR_FOREVER	"forever"
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #ifdef __NSS_PRIVATE_INTERFACE
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate struct __nsw_lookup_v1 {
957c478bd9Sstevel@tonic-gate 	char *service_name;
967c478bd9Sstevel@tonic-gate 	action_t actions[__NSW_STD_ERRS_V1];
977c478bd9Sstevel@tonic-gate 	int max_retries;  /* for TRYAGAIN=N */
987c478bd9Sstevel@tonic-gate 	struct __nsw_long_err *long_errs;
997c478bd9Sstevel@tonic-gate 	struct __nsw_lookup_v1 *next;
1007c478bd9Sstevel@tonic-gate };
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate struct __nsw_switchconfig_v1 {
1037c478bd9Sstevel@tonic-gate 	int vers;
1047c478bd9Sstevel@tonic-gate 	char *dbase;
1057c478bd9Sstevel@tonic-gate 	int num_lookups;
1067c478bd9Sstevel@tonic-gate 	struct __nsw_lookup_v1 *lookups;
1077c478bd9Sstevel@tonic-gate };
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate #define	__NSW_ACTION_V1(lkp, err) 	\
1107c478bd9Sstevel@tonic-gate 	((lkp)->next == NULL ? \
1117c478bd9Sstevel@tonic-gate 		__NSW_RETURN \
1127c478bd9Sstevel@tonic-gate 	: \
1137c478bd9Sstevel@tonic-gate 		((err) >= 0 && (err) < __NSW_STD_ERRS_V1 ? \
1147c478bd9Sstevel@tonic-gate 			(lkp)->actions[err] \
1157c478bd9Sstevel@tonic-gate 		: \
1167c478bd9Sstevel@tonic-gate 			__nsw_extended_action_v1(lkp, err)))
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate struct __nsw_switchconfig_v1 *__nsw_getconfig_v1
1207c478bd9Sstevel@tonic-gate 	(const char *, enum __nsw_parse_err *);
1217c478bd9Sstevel@tonic-gate int __nsw_freeconfig_v1(struct __nsw_switchconfig_v1 *);
1227c478bd9Sstevel@tonic-gate action_t __nsw_extended_action_v1(struct __nsw_lookup_v1 *, int);
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #endif /* __NSS_PRIVATE_INTERFACE */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1277c478bd9Sstevel@tonic-gate }
1287c478bd9Sstevel@tonic-gate #endif
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #endif /* _NSSWITCH_PRIV_H */
131