1*cb5caa98Sdjl /* 2*cb5caa98Sdjl * CDDL HEADER START 3*cb5caa98Sdjl * 4*cb5caa98Sdjl * The contents of this file are subject to the terms of the 5*cb5caa98Sdjl * Common Development and Distribution License (the "License"). 6*cb5caa98Sdjl * You may not use this file except in compliance with the License. 7*cb5caa98Sdjl * 8*cb5caa98Sdjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*cb5caa98Sdjl * or http://www.opensolaris.org/os/licensing. 10*cb5caa98Sdjl * See the License for the specific language governing permissions 11*cb5caa98Sdjl * and limitations under the License. 12*cb5caa98Sdjl * 13*cb5caa98Sdjl * When distributing Covered Code, include this CDDL HEADER in each 14*cb5caa98Sdjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*cb5caa98Sdjl * If applicable, add the following below this CDDL HEADER, with the 16*cb5caa98Sdjl * fields enclosed by brackets "[]" replaced with your own identifying 17*cb5caa98Sdjl * information: Portions Copyright [yyyy] [name of copyright owner] 18*cb5caa98Sdjl * 19*cb5caa98Sdjl * CDDL HEADER END 20*cb5caa98Sdjl */ 21*cb5caa98Sdjl /* 22*cb5caa98Sdjl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*cb5caa98Sdjl * Use is subject to license terms. 24*cb5caa98Sdjl */ 25*cb5caa98Sdjl 26*cb5caa98Sdjl #ifndef _NSCD_FRONTEND_H 27*cb5caa98Sdjl #define _NSCD_FRONTEND_H 28*cb5caa98Sdjl 29*cb5caa98Sdjl #pragma ident "%Z%%M% %I% %E% SMI" 30*cb5caa98Sdjl 31*cb5caa98Sdjl #ifdef __cplusplus 32*cb5caa98Sdjl extern "C" { 33*cb5caa98Sdjl #endif 34*cb5caa98Sdjl 35*cb5caa98Sdjl #include "cache.h" 36*cb5caa98Sdjl 37*cb5caa98Sdjl #define NSCD_LOOKUP_BUFSIZE 1024 * 16 38*cb5caa98Sdjl #define NSCD_DOORBUF_MAXLEN 1024 * 512 39*cb5caa98Sdjl #define NSCD_PHDR_LEN(hdrp) ((hdrp)->data_off) 40*cb5caa98Sdjl #define NSCD_DATA_LEN(hdrp) ((hdrp)->data_len) 41*cb5caa98Sdjl 42*cb5caa98Sdjl #define NSCD_ALLOC_LOOKUP_BUFFER(bufp, bufsiz, hdrp, space, spsiz) \ 43*cb5caa98Sdjl if ((hdrp)->pbufsiz <= spsiz) { \ 44*cb5caa98Sdjl (void) memcpy(space, (hdrp), NSCD_PHDR_LEN((hdrp))); \ 45*cb5caa98Sdjl bufp = space; \ 46*cb5caa98Sdjl bufsiz = spsiz; \ 47*cb5caa98Sdjl hdrp = (nss_pheader_t *)(void *)space; \ 48*cb5caa98Sdjl } else { \ 49*cb5caa98Sdjl (bufp) = NULL; \ 50*cb5caa98Sdjl bufsiz = (hdrp)->pbufsiz; \ 51*cb5caa98Sdjl if (bufsiz > spsiz) \ 52*cb5caa98Sdjl bufsiz = NSCD_DOORBUF_MAXLEN; \ 53*cb5caa98Sdjl (bufp) = alloca(bufsiz); \ 54*cb5caa98Sdjl if ((bufp) != NULL) { \ 55*cb5caa98Sdjl (void) memcpy((bufp), (hdrp), NSCD_PHDR_LEN(hdrp)); \ 56*cb5caa98Sdjl (hdrp) = (nss_pheader_t *)(void *)(bufp); \ 57*cb5caa98Sdjl } else { \ 58*cb5caa98Sdjl NSCD_SET_STATUS((hdrp), NSS_ERROR, ENOMEM); \ 59*cb5caa98Sdjl (void) door_return((char *)(hdrp), \ 60*cb5caa98Sdjl NSCD_PHDR_LEN(hdrp), NULL, 0); \ 61*cb5caa98Sdjl } \ 62*cb5caa98Sdjl } 63*cb5caa98Sdjl 64*cb5caa98Sdjl #define NSCD_SET_RETURN_ARG(hdrp, arg_size) \ 65*cb5caa98Sdjl if (NSCD_STATUS_IS_OK((nss_pheader_t *)(hdrp))) \ 66*cb5caa98Sdjl arg_size = NSCD_PHDR_LEN(hdrp) + (NSCD_DATA_LEN(hdrp) > 0 ? \ 67*cb5caa98Sdjl NSCD_DATA_LEN(hdrp) + 1 : 0); \ 68*cb5caa98Sdjl else \ 69*cb5caa98Sdjl arg_size = NSCD_PHDR_LEN(hdrp); 70*cb5caa98Sdjl 71*cb5caa98Sdjl /* prototypes */ 72*cb5caa98Sdjl uid_t _nscd_get_client_euid(); 73*cb5caa98Sdjl int _nscd_setup_server(char *execname, char **argv); 74*cb5caa98Sdjl int _nscd_setup_child_server(int did); 75*cb5caa98Sdjl int _nscd_get_clearance(sema_t *sema); 76*cb5caa98Sdjl int _nscd_release_clearance(sema_t *sema); 77*cb5caa98Sdjl void _nscd_init_cache_sema(sema_t *sema, char *cache_name); 78*cb5caa98Sdjl nscd_rc_t _nscd_alloc_frontend_cfg(); 79*cb5caa98Sdjl 80*cb5caa98Sdjl #ifdef __cplusplus 81*cb5caa98Sdjl } 82*cb5caa98Sdjl #endif 83*cb5caa98Sdjl 84*cb5caa98Sdjl #endif /* _NSCD_FRONTEND_H */ 85