8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libsldap / common / ns_cache_door.h
blob8e260c4f53fb1d7a0b9051a8b47505e373a69c39
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
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _NS_CACHE_DOOR_H
27 #define _NS_CACHE_DOOR_H
30 * Definitions for client side of doors-based ldap caching
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 #include <netdb.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
40 #include <sys/socket.h>
41 #include <grp.h>
42 #include <pwd.h>
46 * statistics & control structure
49 typedef struct ldap_stat {
50 int ldap_numbercalls; /* number of times called */
51 int ldap_ttl; /* time to live for positive entries */
52 } ldap_stat_t;
56 * Structure used to transfer arrays of strings.
57 * Buffer format:
58 * count
59 * array of offsets from start of buffer
60 * array of characters of strings
61 * charp = buf + ldap_offsets[n];
64 typedef struct ldap_strlist {
65 int ldap_count; /* number of strings */
66 int ldap_offsets[1]; /* array of offsets */
67 } ldap_strlist_t;
70 * Structure used to request/inform config and server status changes.
73 typedef struct ldap_get_chg_cookie {
74 pid_t mgr_pid; /* current process id of ldap_cachemgr */
75 uint32_t seq_num; /* current config sequence number */
76 } ldap_get_chg_cookie_t;
78 typedef struct ldap_get_change {
79 uint32_t op; /* start or stop */
80 ldap_get_chg_cookie_t cookie; /* get status change cookie */
81 } ldap_get_change_t;
83 typedef struct ldap_get_change_out {
84 uint32_t type; /* config change or server change */
85 ldap_get_chg_cookie_t cookie; /* get status change cookie */
86 uint32_t server_count; /* if server change: num of servers */
87 uint32_t data_size; /* if server change: size of data */
88 char data[sizeof (int)]; /* real size is data_size */
89 } ldap_get_change_out_t;
91 typedef struct ldap_config_out {
92 ldap_get_chg_cookie_t cookie; /* get status change cookie */
93 uint32_t data_size; /* length of the config string */
94 char config_str[sizeof (int)]; /* real size is data_size */
95 } ldap_config_out_t;
97 typedef struct ldap_admin_mod_result {
98 uint32_t ns_err; /* ns_ldap error code */
99 uint32_t status; /* error status */
100 uint32_t msg_size; /* length of error message */
101 char msg[sizeof (int)]; /* real size is msg_size */
102 } ldap_admin_mod_result_t;
105 * structure returned by server for all calls
108 #define BUFFERSIZE 8192
109 #define OFFSET 36
111 typedef struct {
112 int ldap_bufferbytesused;
113 int ldap_return_code;
114 int ldap_errno;
116 union {
117 char config[BUFFERSIZE - OFFSET]; /* V1 Config */
118 ldap_stat_t stats;
119 char buff[4];
120 char ber[4]; /* BER/DER encoded packet */
121 ldap_strlist_t strlist;
122 ldap_config_out_t config_str;
123 ldap_get_change_out_t changes;
124 ldap_admin_mod_result_t admin_result;
125 } ldap_u;
127 } ldap_return_t;
130 * calls look like this
133 typedef struct {
134 int ldap_callnumber;
135 union {
136 uid_t uid;
137 gid_t gid;
138 char domainname[sizeof (int)]; /* size is indeterminate */
139 struct {
140 int a_type;
141 int a_length;
142 char a_data[sizeof (int)];
143 } addr;
144 char servername[sizeof (int)]; /* Format: server:port */
145 ldap_strlist_t strlist;
146 ldap_get_change_t get_change;
147 } ldap_u;
148 } ldap_call_t;
150 * how the client views the call process
153 typedef union {
154 ldap_call_t ldap_call;
155 ldap_return_t ldap_ret;
156 char ldap_buff[sizeof (int)];
157 } ldap_data_t;
159 /* Version 1 Cache Manager calls */
160 /* Cache manager ping */
161 #define NULLCALL 0
162 /* NativeLDAP I Get Config */
163 #define GETLDAPCONFIG 1
164 #define GETLDAPCONFIGV1 1
167 * administrative calls
170 #define KILLSERVER 7
171 #define GETADMIN 8
172 #define SETADMIN 9
175 * debug levels
178 #define DBG_OFF 0
179 #define DBG_CANT_FIND 1
180 #define DBG_NETLOOKUPS 2
181 #define DBG_SERVER_LIST_REFRESH 3 /* debug server list refresh */
182 #define DBG_PROFILE_REFRESH 4 /* debug profile TTL/refresh */
183 #define DBG_ALL 6
185 /* Version 2 Cache Manager calls */
186 /* NativeLDAP II Get Server and RootDSE Info */
187 #define GETLDAPSERVER 21
188 /* NativeLDAP II Get cached data */
189 #define GETCACHE 22
190 /* NativeLDAP II Set cached data */
191 #define SETCACHE 23
192 /* NativeLDAP II get cache data statistics */
193 #define GETCACHESTAT 24
194 /* Configuration change or server status change notification */
195 #define GETSTATUSCHANGE 25
196 /* perform admin modify via ldap_cachemgr */
197 #define ADMINMODIFY 26
198 /* get admin credentials for shadow lookups */
199 #define GETADMINCRED 27
202 * GETLDAPSERVER request flags
205 #define NS_CACHE_NEW "0"
206 #define NS_CACHE_NORESP "1"
207 #define NS_CACHE_NEXT "2"
208 #define NS_CACHE_WRITE "3"
209 #define NS_CACHE_ADDR_HOSTNAME "H"
210 #define NS_CACHE_ADDR_IP "I"
213 * GETSTATUSCHANGE operation: start or stop
215 #define NS_STATUS_CHANGE_OP_START 1
216 #define NS_STATUS_CHANGE_OP_STOP 2
219 * GETSTATUSCHANGE change type: config or server
221 #define NS_STATUS_CHANGE_TYPE_CONFIG 1
222 #define NS_STATUS_CHANGE_TYPE_SERVER 2
225 * Server status change
227 #define NS_SERVER_CHANGE_UP "0" /* mapped to NS_SERVER_UP */
228 #define NS_SERVER_CHANGE_DOWN "1" /* mapped to NS_SERVER_DOWN */
230 * GETCACHE/SETCACHE data flags
232 #define NS_CACHE_DN2DOMAIN "DM"
235 * Max size name we allow to be passed to avoid
236 * buffer overflow problems
238 #define LDAPMAXNAMELEN 255
241 * defines for client-server interaction
244 #define LDAP_CACHE_DOOR_VERSION 1
245 #define LDAP_CACHE_DOOR "/var/run/ldap_cache_door"
246 #define LDAP_CACHE_DOOR_COOKIE ((void*)(0xdeadbeef^LDAP_CACHE_DOOR_VERSION))
247 #define UPDATE_DOOR_COOKIE ((void*)(0xdeadcafe)
249 #define NS_CACHE_SUCCESS 0
250 #define NS_CACHE_NOTFOUND -1
251 #define NS_CACHE_CREDERROR -2
252 #define NS_CACHE_SERVERERROR -3
253 #define NS_CACHE_NOSERVER -4
256 __ns_ldap_trydoorcall(ldap_data_t **dptr, int *ndata, int *adata);
258 __ns_ldap_trydoorcall_getfd();
260 __ns_ldap_trydoorcall_send(ldap_data_t **dptr, int *ndata, int *adata);
261 void
262 __ns_ldap_doorfd_close();
264 #ifdef __cplusplus
266 #endif
269 #endif /* _NS_CACHE_DOOR_H */