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]
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
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
40 #include <sys/socket.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 */
56 * Structure used to transfer arrays of strings.
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 */
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 */
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 */
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
112 int ldap_bufferbytesused
;
113 int ldap_return_code
;
117 char config
[BUFFERSIZE
- OFFSET
]; /* V1 Config */
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
;
130 * calls look like this
138 char domainname
[sizeof (int)]; /* size is indeterminate */
142 char a_data
[sizeof (int)];
144 char servername
[sizeof (int)]; /* Format: server:port */
145 ldap_strlist_t strlist
;
146 ldap_get_change_t get_change
;
150 * how the client views the call process
154 ldap_call_t ldap_call
;
155 ldap_return_t ldap_ret
;
156 char ldap_buff
[sizeof (int)];
159 /* Version 1 Cache Manager calls */
160 /* Cache manager ping */
162 /* NativeLDAP I Get Config */
163 #define GETLDAPCONFIG 1
164 #define GETLDAPCONFIGV1 1
167 * administrative calls
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 */
185 /* Version 2 Cache Manager calls */
186 /* NativeLDAP II Get Server and RootDSE Info */
187 #define GETLDAPSERVER 21
188 /* NativeLDAP II Get cached data */
190 /* NativeLDAP II Set cached data */
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
);
262 __ns_ldap_doorfd_close();
269 #endif /* _NS_CACHE_DOOR_H */