1 /* slap.h - stand alone ldap server include file */
10 #include <sys/types.h>
11 #include <ac/syslog.h>
21 #include "lthread_rdwr.h"
31 #define MAXREMATCHES 10
36 * represents an attribute value assertion (i.e., attr=value)
40 struct berval ava_value;
44 * represents a search filter
46 typedef struct filter {
47 unsigned long f_choice; /* values taken from ldap.h */
53 /* equality, lessorequal, greaterorequal, approx */
57 struct filter *f_un_complex;
62 char *f_un_sub_initial;
67 #define f_type f_un.f_un_type
68 #define f_ava f_un.f_un_ava
69 #define f_avtype f_un.f_un_ava.ava_type
70 #define f_avvalue f_un.f_un_ava.ava_value
71 #define f_and f_un.f_un_complex
72 #define f_or f_un.f_un_complex
73 #define f_not f_un.f_un_complex
74 #define f_list f_un.f_un_complex
75 #define f_sub f_un.f_un_sub
76 #define f_sub_type f_un.f_un_sub.f_un_sub_type
77 #define f_sub_initial f_un.f_un_sub.f_un_sub_initial
78 #define f_sub_any f_un.f_un_sub.f_un_sub_any
79 #define f_sub_final f_un.f_un_sub.f_un_sub_final
81 struct filter *f_next;
85 * represents an attribute (type + values + syntax)
89 struct berval **a_vals;
95 * the attr_syntax() routine returns one of these values
96 * telling what kind of syntax an attribute supports.
98 #define SYNTAX_CIS 0x01 /* case insensitive string */
99 #define SYNTAX_CES 0x02 /* case sensitive string */
100 #define SYNTAX_BIN 0x04 /* binary data */
101 #define SYNTAX_TEL 0x08 /* telephone number string */
102 #define SYNTAX_DN 0x10 /* dn string */
105 * the id used in the indexes to refer to an entry
107 typedef unsigned long ID;
108 #define NOID ((unsigned long)-1)
111 * represents an entry in core
113 typedef struct entry {
114 char *e_dn; /* DN of this entry */
115 Attribute *e_attrs; /* list of attributes + values */
117 ID e_id; /* id of this entry - this should */
118 /* really be private to back-ldbm */
119 char e_state; /* for the cache */
121 pthread_rdwr_t e_rdwr; /* reader/writer lock */
123 #define ENTRY_STATE_DELETED 1
124 #define ENTRY_STATE_CREATING 2
125 int e_refcnt; /* # threads ref'ing this entry */
126 struct entry *e_lrunext; /* for cache lru list */
127 struct entry *e_lruprev;
131 * represents an access control list
142 #ifdef SLAPD_ACLGROUPS
146 #define ACL_NONE 0x01
147 #define ACL_COMPARE 0x02
148 #define ACL_SEARCH 0x04
149 #define ACL_READ 0x08
150 #define ACL_WRITE 0x10
151 #define ACL_SELF 0x40
152 struct access *a_next;
157 /* "to" part: the entries this acl applies to */
163 /* "by" part: list of who has what access to the entries */
164 struct access *acl_access;
166 struct acl *acl_next;
170 * represents schema information for a database
177 struct objclass *oc_next;
181 * represents a "database"
184 typedef struct backend {
185 char **be_suffix; /* the DN suffixes of data in this backend */
186 char *be_rootdn; /* the magic "root" dn for this db */
187 char *be_rootpw; /* the magic "root" password for this db */
188 int be_readonly; /* 1 => db is in "read only" mode */
189 int be_sizelimit; /* size limit for this backend */
190 int be_timelimit; /* time limit for this backend */
191 struct acl *be_acl; /* access control list for this backend */
192 int be_dfltaccess; /* access given if no acl matches */
193 char **be_replica; /* replicas of this backend (in master) */
194 char *be_replogfile; /* replication log file (in master) */
195 char *be_updatedn; /* allowed to make changes (in replicas) */
196 int be_lastmod; /* keep track of lastmodified{by,time} */
197 char *be_type; /* type of database */
199 void *be_private; /* anything the backend needs */
201 IFP be_bind; /* backend bind routine */
202 IFP be_unbind; /* backend unbind routine */
203 IFP be_search; /* backend search routine */
204 IFP be_compare; /* backend compare routine */
205 IFP be_modify; /* backend modify routine */
206 IFP be_modrdn; /* backend modrdn routine */
207 IFP be_add; /* backend add routine */
208 IFP be_delete; /* backend delete routine */
209 IFP be_abandon; /* backend abandon routine */
210 IFP be_config; /* backend config routine */
211 IFP be_init; /* backend init routine */
212 IFP be_close; /* backend close routine */
214 #ifdef SLAPD_ACLGROUPS
215 IFP be_group; /* backend group member test */
220 * represents an operation pending from an ldap client
224 BerElement *o_ber; /* ber of the request */
225 long o_msgid; /* msgid of the request */
226 unsigned long o_tag; /* tag of the request */
227 time_t o_time; /* time op was initiated */
228 char *o_dn; /* dn bound when op was initiated */
229 int o_authtype; /* auth method used to bind dn */
230 /* values taken from ldap.h */
232 int o_opid; /* id of this operation */
233 int o_connid; /* id of conn initiating this op */
234 #ifdef LDAP_CONNECTIONLESS
235 int o_cldap; /* != 0 if this came in via CLDAP */
236 struct sockaddr o_clientaddr; /* client address if via CLDAP */
237 char o_searchbase; /* search base if via CLDAP */
239 struct op *o_next; /* next operation pending */
240 pthread_t o_tid; /* thread handling this op */
241 int o_abandon; /* signals op has been abandoned */
242 pthread_mutex_t o_abandonmutex; /* signals op has been abandoned */
244 int o_private; /* anything the backend needs */
248 * represents a connection from an ldap client
251 typedef struct conn {
252 Sockbuf c_sb; /* ber connection stuff */
253 char *c_dn; /* current DN bound to this conn */
254 pthread_mutex_t c_dnmutex; /* mutex for c_dn field */
255 int c_authtype; /* auth method used to bind c_dn */
257 int c_version; /* for compatibility w/2.0, 3.0 */
259 char *c_addr; /* address of client on this conn */
260 char *c_domain; /* domain of client on this conn */
261 Operation *c_ops; /* list of pending operations */
262 pthread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */
263 pthread_mutex_t c_pdumutex; /* only one pdu written at a time */
264 pthread_cond_t c_wcv; /* used to wait for sd write-ready*/
265 int c_gettingber; /* in the middle of ber_get_next */
266 BerElement *c_currentber; /* ber we're getting */
267 int c_writewaiter; /* signals write-ready sd waiter */
268 int c_pduwaiters; /* signals threads waiting 4 pdu */
269 time_t c_starttime; /* when the connection was opened */
270 int c_connid; /* id of this connection for stats*/
271 int c_opsinitiated; /* # ops initiated/next op id */
272 int c_opscompleted; /* # ops completed */
275 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
276 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
278 if ( ldap_debug & level ) \
279 fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
280 if ( ldap_syslog & level ) \
281 syslog( ldap_syslog_level, fmt, connid, opid, arg1, \
285 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
288 #include "proto-slap.h"
292 #endif /* _slap_h_ */