nscd_frontend.h revision 2830:5228d1267a01
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
32extern "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 */
72uid_t _nscd_get_client_euid();
73int _nscd_setup_server(char *execname, char **argv);
74int _nscd_setup_child_server(int did);
75int _nscd_get_clearance(sema_t *sema);
76int _nscd_release_clearance(sema_t *sema);
77void _nscd_init_cache_sema(sema_t *sema, char *cache_name);
78nscd_rc_t _nscd_alloc_frontend_cfg();
79
80#ifdef	__cplusplus
81}
82#endif
83
84#endif	/* _NSCD_FRONTEND_H */
85