8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / nscd / nscd_door.h
blob0949e8ed8ea22045d0bef711bc40a29fbdbce909
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2012 Milan Jurik. All rights reserved.
28 #ifndef _NSCD_DOOR_H
29 #define _NSCD_DOOR_H
32 * Definitions for nscd to nscd door interfaces
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #include <alloca.h>
40 #include <nss_dbdefs.h>
42 /* door for Trusted Extensions */
43 #define TSOL_NAME_SERVICE_DOOR "/var/tsol/doors/name_service_door"
44 /* TX per label nscd indication file */
45 #define TSOL_NSCD_PER_LABEL_FILE "/var/tsol/doors/nscd_per_label"
47 /* nscd v2 nscd -> nscd call numbers */
48 #define NSCD_PING (NSCD_CALLCAT_N2N|0x01)
49 #define NSCD_GETADMIN (NSCD_CALLCAT_N2N|0x02)
50 #define NSCD_SETADMIN (NSCD_CALLCAT_N2N|0x03)
51 #define NSCD_GETPUADMIN (NSCD_CALLCAT_N2N|0x04)
52 #define NSCD_SETPUADMIN (NSCD_CALLCAT_N2N|0x05)
53 #define NSCD_KILLSERVER (NSCD_CALLCAT_N2N|0x06)
55 #define NSCD_IMHERE (NSCD_CALLCAT_N2N|0x10) /* IMHERE+WHOAMI */
56 #define NSCD_FORK (NSCD_CALLCAT_N2N|0x20)
57 #define NSCD_SETUID (NSCD_CALLCAT_N2N|0x30)
58 #define NSCD_KILL (NSCD_CALLCAT_N2N|0x40)
59 #define NSCD_PULSE (NSCD_CALLCAT_N2N|0x50)
60 #define NSCD_REFRESH (NSCD_CALLCAT_N2N|0x60)
62 /* nscd v2 nscd identities */
64 #define NSCD_MAIN 0x00000001
65 #define NSCD_FORKER 0x00000002
66 #define NSCD_CHILD 0x00000004
67 #define NSCD_WHOAMI 0x0000000F
69 #define NSCD_ALLOC_DOORBUF(cn, dsz, uptr, usz) \
70 usz = (sizeof (nss_pheader_t) + (dsz)); \
71 uptr = alloca(usz); \
72 (void) memset(uptr, 0, usz); \
73 ((nss_pheader_t *)uptr)->nsc_callnumber = (cn); \
74 ((nss_pheader_t *)uptr)->p_version = NSCD_HEADER_REV; \
75 ((nss_pheader_t *)uptr)->pbufsiz = usz; \
76 ((nss_pheader_t *)uptr)->data_off = sizeof (nss_pheader_t); \
77 ((nss_pheader_t *)uptr)->key_off = sizeof (nss_pheader_t); \
78 ((nss_pheader_t *)uptr)->dbd_off = sizeof (nss_pheader_t); \
79 ((nss_pheader_t *)uptr)->data_len = dsz;
81 #define NSCD_N2N_DOOR_DATA(type, buf) \
82 (type *)((void *)(((char *)(buf)) + sizeof (nss_pheader_t)))
84 #define NSCD_N2N_DOOR_BUF_SIZE(struct) \
85 sizeof (nss_pheader_t) + sizeof (struct)
87 #define NSCD_SET_STATUS(ph, st, errno) \
88 { \
89 int e = errno; \
90 (ph)->p_status = st; \
91 if (e != -1) \
92 (ph)->p_errno = e; \
95 #define NSCD_SET_HERRNO(ph, herrno) \
96 (ph)->p_herrno = herrno;
99 #define NSCD_SET_STATUS_SUCCESS(ph) \
100 (ph)->p_status = NSS_SUCCESS; \
101 (ph)->p_errno = 0;
103 #define NSCD_SET_N2N_STATUS(ph, st, errno, n2nst) \
105 int e = errno; \
106 (ph)->p_status = st; \
107 if (e != -1) \
108 (ph)->p_errno = e; \
109 (ph)->nscdpriv = n2nst; \
112 #define NSCD_STATUS_IS_OK(ph) \
113 (((ph)->p_status) == NSS_SUCCESS)
115 #define NSCD_STATUS_IS_NOT_OK(ph) \
116 (((ph)->p_status) != NSS_SUCCESS)
118 #define NSCD_GET_STATUS(ph) \
119 (((nss_pheader_t *)(ph))->p_status)
121 #define NSCD_GET_ERRNO(ph) \
122 (((nss_pheader_t *)(ph))->p_errno)
124 #define NSCD_GET_HERRNO(ph) \
125 (((nss_pheader_t *)(ph))->p_herrno)
127 #define NSCD_GET_NSCD_STATUS(ph) \
128 (((nss_pheader_t *)(ph))->nscdpriv)
130 #define NSCD_CLEAR_STATUS(ph) \
131 (ph)->p_status = 0; \
132 (ph)->p_errno = 0; \
133 (ph)->nscdpriv = 0;
135 #define NSCD_COPY_STATUS(ph, ph1) \
136 (ph)->p_status = (ph1)->p_status; \
137 (ph)->p_errno = (ph1)->p_errno; \
138 (ph)->nscdpriv = (ph1)->nscdpriv;
140 nss_status_t _nscd_doorcall(int callnum);
141 nss_status_t _nscd_doorcall_data(int callnum, void *indata,
142 int indlen, void *outdata, int outdlen,
143 nss_pheader_t *phdr);
145 nss_status_t _nscd_doorcall_fd(int fd, int callnum, void *indata,
146 int indlen, void *outdata, int outdlen,
147 nss_pheader_t *phdr);
149 nss_status_t _nscd_doorcall_sendfd(int fd, int callnum,
150 void *indata, int indlen, nss_pheader_t *phdr);
152 #ifdef __cplusplus
154 #endif
156 #endif /* _NSCD_DOOR_H */