xref: /titanic_51/usr/src/cmd/nscd/nscd_frontend.h (revision 40e5e17b3361b3eea56a9723071c406894a20b78)
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 #ifndef _NSCD_FRONTEND_H
27 #define	_NSCD_FRONTEND_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include "cache.h"
36 
37 #define	NSCD_LOOKUP_BUFSIZE	1024 * 16
38 #define	NSCD_DOORBUF_MAXLEN	1024 * 512
39 #define	NSCD_PHDR_LEN(hdrp)	((hdrp)->data_off)
40 #define	NSCD_DATA_LEN(hdrp)	((hdrp)->data_len)
41 
42 #define	NSCD_ALLOC_LOOKUP_BUFFER(bufp, bufsiz, hdrp, space, spsiz)  \
43 	if ((hdrp)->pbufsiz <= spsiz) { \
44 		(void) memcpy(space, (hdrp), NSCD_PHDR_LEN((hdrp))); \
45 		bufp = space; \
46 		bufsiz = spsiz; \
47 		hdrp = (nss_pheader_t *)(void *)space; \
48 	} else { \
49 		(bufp) = NULL; \
50 		bufsiz = (hdrp)->pbufsiz; \
51 		if (bufsiz > spsiz) \
52 			bufsiz = NSCD_DOORBUF_MAXLEN; \
53 		(bufp) = alloca(bufsiz); \
54 		if ((bufp) != NULL) { \
55 			(void) memcpy((bufp), (hdrp), NSCD_PHDR_LEN(hdrp)); \
56 			(hdrp) = (nss_pheader_t *)(void *)(bufp); \
57 		} else { \
58 			NSCD_SET_STATUS((hdrp), NSS_ERROR, ENOMEM); \
59 			(void) door_return((char *)(hdrp), \
60 				NSCD_PHDR_LEN(hdrp), NULL, 0); \
61 		} \
62 	}
63 
64 #define	NSCD_SET_RETURN_ARG(hdrp, arg_size)  \
65 	if (NSCD_STATUS_IS_OK((nss_pheader_t *)(hdrp))) \
66 		arg_size = NSCD_PHDR_LEN(hdrp) + (NSCD_DATA_LEN(hdrp) > 0 ? \
67 		NSCD_DATA_LEN(hdrp) + 1 : 0); \
68 	else \
69 		arg_size = NSCD_PHDR_LEN(hdrp);
70 
71 /* prototypes */
72 uid_t _nscd_get_client_euid();
73 int _nscd_setup_server(char *execname, char **argv);
74 int _nscd_setup_child_server(int did);
75 int _nscd_get_clearance(sema_t *sema);
76 int _nscd_release_clearance(sema_t *sema);
77 void _nscd_init_cache_sema(sema_t *sema, char *cache_name);
78 nscd_rc_t _nscd_alloc_frontend_cfg();
79 void _nscd_APP_check_cred(void *buf, pid_t *pidp, char *dc_str,
80 	int log_comp, int log_level);
81 #ifdef	__cplusplus
82 }
83 #endif
84 
85 #endif	/* _NSCD_FRONTEND_H */
86