1 /* slap.h - stand alone ldap server include file */
12 #include <sys/types.h>
13 #include <ac/syslog.h>
23 #include "ldap_pvt_thread.h"
27 #undef f_next /* name conflict between sys/file.h on SCO and struct filter */
37 #define MAXREMATCHES 10
39 #define DNSEPARATOR(c) ((c) == ',' || (c) == ';')
40 #define SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '+')
41 #define SPACE(c) ((c) == ' ' || (c) == '\n')
42 #define NEEDSESCAPE(c) ((c) == '\\' || (c) == '"')
50 * represents an attribute value assertion (i.e., attr=value)
54 struct berval ava_value;
58 * represents a search filter
60 typedef struct filter {
61 unsigned long f_choice; /* values taken from ldap.h */
67 /* equality, lessorequal, greaterorequal, approx */
71 struct filter *f_un_complex;
76 char *f_un_sub_initial;
81 #define f_type f_un.f_un_type
82 #define f_ava f_un.f_un_ava
83 #define f_avtype f_un.f_un_ava.ava_type
84 #define f_avvalue f_un.f_un_ava.ava_value
85 #define f_and f_un.f_un_complex
86 #define f_or f_un.f_un_complex
87 #define f_not f_un.f_un_complex
88 #define f_list f_un.f_un_complex
89 #define f_sub f_un.f_un_sub
90 #define f_sub_type f_un.f_un_sub.f_un_sub_type
91 #define f_sub_initial f_un.f_un_sub.f_un_sub_initial
92 #define f_sub_any f_un.f_un_sub.f_un_sub_any
93 #define f_sub_final f_un.f_un_sub.f_un_sub_final
95 struct filter *f_next;
99 * represents an attribute (type + values + syntax)
101 typedef struct attr {
103 struct berval **a_vals;
109 * the attr_syntax() routine returns one of these values
110 * telling what kind of syntax an attribute supports.
112 #define SYNTAX_CIS 0x01 /* case insensitive string */
113 #define SYNTAX_CES 0x02 /* case sensitive string */
114 #define SYNTAX_BIN 0x04 /* binary data */
115 #define SYNTAX_TEL 0x08 /* telephone number string */
116 #define SYNTAX_DN 0x10 /* dn string */
119 * the id used in the indexes to refer to an entry
121 typedef unsigned long ID;
122 #define NOID ((unsigned long)-1)
125 * represents an entry in core
127 typedef struct entry {
128 char *e_dn; /* DN of this entry */
129 char *e_ndn; /* normalized DN of this entry */
130 Attribute *e_attrs; /* list of attributes + values */
132 ID e_id; /* id of this entry - this should */
133 /* really be private to back-ldbm */
134 char e_state; /* for the cache */
136 ldap_pvt_thread_rdwr_t e_rdwr; /* reader/writer lock */
138 #define ENTRY_STATE_DELETED 1
139 #define ENTRY_STATE_CREATING 2
140 int e_refcnt; /* # threads ref'ing this entry */
141 struct entry *e_lrunext; /* for cache lru list */
142 struct entry *e_lruprev;
146 * represents an access control list
157 #ifdef SLAPD_ACLGROUPS
159 char *a_objectclassvalue;
160 char *a_groupattrname;
163 #define ACL_NONE 0x01
164 #define ACL_COMPARE 0x02
165 #define ACL_SEARCH 0x04
166 #define ACL_READ 0x08
167 #define ACL_WRITE 0x10
168 #define ACL_SELF 0x40
169 struct access *a_next;
174 /* "to" part: the entries this acl applies to */
180 /* "by" part: list of who has what access to the entries */
181 struct access *acl_access;
183 struct acl *acl_next;
187 * represents schema information for a database
194 struct objclass *oc_next;
198 * represents a "database"
201 typedef struct backend Backend;
203 char **be_suffix; /* the DN suffixes of data in this backend */
204 char **be_suffixAlias; /* the DN suffix aliases of data in this backend */
205 char *be_root_dn; /* the magic "root" dn for this db */
206 char *be_root_ndn; /* the magic "root" normalized dn for this db */
207 char *be_root_pw; /* the magic "root" password for this db */
208 int be_readonly; /* 1 => db is in "read only" mode */
209 int be_maxDerefDepth; /* limit for depth of an alias deref */
210 int be_sizelimit; /* size limit for this backend */
211 int be_timelimit; /* time limit for this backend */
212 struct acl *be_acl; /* access control list for this backend */
213 int be_dfltaccess; /* access given if no acl matches */
214 char **be_replica; /* replicas of this backend (in master) */
215 char *be_replogfile; /* replication log file (in master) */
216 char *be_update_ndn; /* allowed to make changes (in replicas) */
217 int be_lastmod; /* keep track of lastmodified{by,time} */
218 char *be_type; /* type of database */
220 void *be_private; /* anything the backend needs */
222 /* backend routines */
223 int (*be_bind) LDAP_P((Backend *be,
224 struct slap_conn *c, struct slap_op *o,
225 char *dn, int method, struct berval *cred, char** edn ));
226 void (*be_unbind) LDAP_P((Backend *be,
227 struct slap_conn *c, struct slap_op *o ));
228 int (*be_search) LDAP_P((Backend *be,
229 struct slap_conn *c, struct slap_op *o,
230 char *base, int scope, int deref, int slimit, int tlimit,
231 Filter *f, char *filterstr, char **attrs, int attrsonly));
232 int (*be_compare)LDAP_P((Backend *be,
233 struct slap_conn *c, struct slap_op *o,
234 char *dn, Ava *ava));
235 int (*be_modify) LDAP_P((Backend *be,
236 struct slap_conn *c, struct slap_op *o,
237 char *dn, LDAPMod *m));
238 int (*be_modrdn) LDAP_P((Backend *be,
239 struct slap_conn *c, struct slap_op *o,
240 char *dn, char *newrdn, int deleteoldrdn ));
241 int (*be_add) LDAP_P((Backend *be,
242 struct slap_conn *c, struct slap_op *o,
244 int (*be_delete) LDAP_P((Backend *be,
245 struct slap_conn *c, struct slap_op *o,
247 /* Bug: be_abandon in unused! */
248 void (*be_abandon)LDAP_P((Backend *be,
249 struct slap_conn *c, struct slap_op *o,
251 void (*be_config) LDAP_P((Backend *be,
252 char *fname, int lineno, int argc, char **argv ));
253 void (*be_init) LDAP_P((Backend *be));
254 void (*be_close) LDAP_P((Backend *be));
256 #ifdef SLAPD_ACLGROUPS
257 int (*be_group) LDAP_P((Backend *be, Entry *e,
258 char *bdn, char *edn,
259 char *objectclassValue, char *groupattrName ));
264 * represents an operation pending from an ldap client
267 typedef struct slap_op {
268 BerElement *o_ber; /* ber of the request */
269 long o_msgid; /* msgid of the request */
270 unsigned long o_tag; /* tag of the request */
271 time_t o_time; /* time op was initiated */
272 char *o_dn; /* dn bound when op was initiated */
273 char *o_ndn; /* normalized dn bound when op was initiated */
274 int o_authtype; /* auth method used to bind dn */
275 /* values taken from ldap.h */
277 int o_opid; /* id of this operation */
278 int o_connid; /* id of conn initiating this op */
279 #ifdef LDAP_CONNECTIONLESS
280 int o_cldap; /* != 0 if this came in via CLDAP */
281 struct sockaddr o_clientaddr; /* client address if via CLDAP */
282 char o_searchbase; /* search base if via CLDAP */
284 struct slap_op *o_next; /* next operation pending */
285 ldap_pvt_thread_t o_tid; /* thread handling this op */
286 int o_abandon; /* signals op has been abandoned */
287 ldap_pvt_thread_mutex_t o_abandonmutex; /* signals op has been abandoned */
289 void *o_private; /* anything the backend needs */
293 * represents a connection from an ldap client
296 typedef struct slap_conn {
297 Sockbuf c_sb; /* ber connection stuff */
298 char *c_cdn; /* DN provided by the client */
299 char *c_dn; /* DN bound to this conn */
300 ldap_pvt_thread_mutex_t c_dnmutex; /* mutex for c_dn field */
301 int c_authtype; /* auth method used to bind c_dn */
303 int c_version; /* for compatibility w/2.0, 3.0 */
305 char *c_addr; /* address of client on this conn */
306 char *c_domain; /* domain of client on this conn */
307 Operation *c_ops; /* list of pending operations */
308 ldap_pvt_thread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */
309 ldap_pvt_thread_mutex_t c_pdumutex; /* only one pdu written at a time */
310 ldap_pvt_thread_cond_t c_wcv; /* used to wait for sd write-ready*/
311 int c_gettingber; /* in the middle of ber_get_next */
312 BerElement *c_currentber; /* ber we're getting */
313 int c_writewaiter; /* signals write-ready sd waiter */
314 int c_pduwaiters; /* signals threads waiting 4 pdu */
315 time_t c_starttime; /* when the connection was opened */
316 int c_connid; /* id of this connection for stats*/
317 int c_opsinitiated; /* # ops initiated/next op id */
318 int c_opscompleted; /* # ops completed */
321 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
322 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
324 if ( ldap_debug & level ) \
325 fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
326 if ( ldap_syslog & level ) \
327 syslog( ldap_syslog_level, fmt, connid, opid, arg1, \
331 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
334 #include "proto-slap.h"
338 #endif /* _slap_h_ */