1 /* slap.h - stand alone ldap server include file */
12 #include <sys/types.h>
13 #include <ac/syslog.h>
23 #include "lthread_rdwr.h"
26 #undef f_next /* name conflict between sys/file.h on SCO and struct filter */
36 #define MAXREMATCHES 10
44 * represents an attribute value assertion (i.e., attr=value)
48 struct berval ava_value;
52 * represents a search filter
54 typedef struct filter {
55 unsigned long f_choice; /* values taken from ldap.h */
61 /* equality, lessorequal, greaterorequal, approx */
65 struct filter *f_un_complex;
70 char *f_un_sub_initial;
75 #define f_type f_un.f_un_type
76 #define f_ava f_un.f_un_ava
77 #define f_avtype f_un.f_un_ava.ava_type
78 #define f_avvalue f_un.f_un_ava.ava_value
79 #define f_and f_un.f_un_complex
80 #define f_or f_un.f_un_complex
81 #define f_not f_un.f_un_complex
82 #define f_list f_un.f_un_complex
83 #define f_sub f_un.f_un_sub
84 #define f_sub_type f_un.f_un_sub.f_un_sub_type
85 #define f_sub_initial f_un.f_un_sub.f_un_sub_initial
86 #define f_sub_any f_un.f_un_sub.f_un_sub_any
87 #define f_sub_final f_un.f_un_sub.f_un_sub_final
89 struct filter *f_next;
93 * represents an attribute (type + values + syntax)
97 struct berval **a_vals;
103 * the attr_syntax() routine returns one of these values
104 * telling what kind of syntax an attribute supports.
106 #define SYNTAX_CIS 0x01 /* case insensitive string */
107 #define SYNTAX_CES 0x02 /* case sensitive string */
108 #define SYNTAX_BIN 0x04 /* binary data */
109 #define SYNTAX_TEL 0x08 /* telephone number string */
110 #define SYNTAX_DN 0x10 /* dn string */
113 * the id used in the indexes to refer to an entry
115 typedef unsigned long ID;
116 #define NOID ((unsigned long)-1)
119 * represents an entry in core
121 typedef struct entry {
122 char *e_dn; /* DN of this entry */
123 Attribute *e_attrs; /* list of attributes + values */
125 ID e_id; /* id of this entry - this should */
126 /* really be private to back-ldbm */
127 char e_state; /* for the cache */
129 pthread_rdwr_t e_rdwr; /* reader/writer lock */
131 #define ENTRY_STATE_DELETED 1
132 #define ENTRY_STATE_CREATING 2
133 int e_refcnt; /* # threads ref'ing this entry */
134 struct entry *e_lrunext; /* for cache lru list */
135 struct entry *e_lruprev;
139 * represents an access control list
150 #ifdef SLAPD_ACLGROUPS
152 char *a_objectclassvalue;
153 char *a_groupattrname;
156 #define ACL_NONE 0x01
157 #define ACL_COMPARE 0x02
158 #define ACL_SEARCH 0x04
159 #define ACL_READ 0x08
160 #define ACL_WRITE 0x10
161 #define ACL_SELF 0x40
162 struct access *a_next;
167 /* "to" part: the entries this acl applies to */
173 /* "by" part: list of who has what access to the entries */
174 struct access *acl_access;
176 struct acl *acl_next;
180 * represents schema information for a database
187 struct objclass *oc_next;
191 * represents a "database"
194 typedef struct backend Backend;
196 char **be_suffix; /* the DN suffixes of data in this backend */
197 char **be_suffixAlias; /* the DN suffix aliases of data in this backend */
198 char *be_rootdn; /* the magic "root" dn for this db */
199 char *be_rootpw; /* the magic "root" password for this db */
200 int be_readonly; /* 1 => db is in "read only" mode */
201 int be_maxDerefDepth; /* limit for depth of an alias deref */
202 int be_sizelimit; /* size limit for this backend */
203 int be_timelimit; /* time limit for this backend */
204 struct acl *be_acl; /* access control list for this backend */
205 int be_dfltaccess; /* access given if no acl matches */
206 char **be_replica; /* replicas of this backend (in master) */
207 char *be_replogfile; /* replication log file (in master) */
208 char *be_updatedn; /* allowed to make changes (in replicas) */
209 int be_lastmod; /* keep track of lastmodified{by,time} */
210 char *be_type; /* type of database */
212 void *be_private; /* anything the backend needs */
214 /* backend routines */
215 int (*be_bind) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, int method, struct berval *cred ));
216 void (*be_unbind) LDAP_P((Backend *be, struct conn *c, struct op *o ));
217 int (*be_search) LDAP_P((Backend *be, struct conn *c, struct op *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
218 int (*be_compare)LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, Ava *ava));
219 int (*be_modify) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, LDAPMod *m));
220 int (*be_modrdn) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, char *newrdn, int deleteoldrdn ));
221 int (*be_add) LDAP_P((Backend *be, struct conn *c, struct op *o, Entry *e));
222 int (*be_delete) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn));
223 /* Bug: be_abandon in unused! */
224 void (*be_abandon)LDAP_P((Backend *be, struct conn *c, struct op *o, int msgid));
225 void (*be_config) LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
226 void (*be_init) LDAP_P((Backend *be));
227 void (*be_close) LDAP_P((Backend *be));
229 #ifdef SLAPD_ACLGROUPS
230 int (*be_group) LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName ));
235 * represents an operation pending from an ldap client
239 BerElement *o_ber; /* ber of the request */
240 long o_msgid; /* msgid of the request */
241 unsigned long o_tag; /* tag of the request */
242 time_t o_time; /* time op was initiated */
243 char *o_dn; /* dn bound when op was initiated */
244 char *o_suffix; /* suffix if aliased */
245 char *o_suffixAliased; /* pending suffix translation */
246 int o_authtype; /* auth method used to bind dn */
247 /* values taken from ldap.h */
249 int o_opid; /* id of this operation */
250 int o_connid; /* id of conn initiating this op */
251 #ifdef LDAP_CONNECTIONLESS
252 int o_cldap; /* != 0 if this came in via CLDAP */
253 struct sockaddr o_clientaddr; /* client address if via CLDAP */
254 char o_searchbase; /* search base if via CLDAP */
256 struct op *o_next; /* next operation pending */
257 pthread_t o_tid; /* thread handling this op */
258 int o_abandon; /* signals op has been abandoned */
259 pthread_mutex_t o_abandonmutex; /* signals op has been abandoned */
261 int o_private; /* anything the backend needs */
265 * represents a connection from an ldap client
268 typedef struct conn {
269 Sockbuf c_sb; /* ber connection stuff */
270 char *c_dn; /* current DN bound to this conn */
271 pthread_mutex_t c_dnmutex; /* mutex for c_dn field */
272 int c_authtype; /* auth method used to bind c_dn */
274 int c_version; /* for compatibility w/2.0, 3.0 */
276 char *c_addr; /* address of client on this conn */
277 char *c_domain; /* domain of client on this conn */
278 Operation *c_ops; /* list of pending operations */
279 pthread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */
280 pthread_mutex_t c_pdumutex; /* only one pdu written at a time */
281 pthread_cond_t c_wcv; /* used to wait for sd write-ready*/
282 int c_gettingber; /* in the middle of ber_get_next */
283 BerElement *c_currentber; /* ber we're getting */
284 int c_writewaiter; /* signals write-ready sd waiter */
285 int c_pduwaiters; /* signals threads waiting 4 pdu */
286 time_t c_starttime; /* when the connection was opened */
287 int c_connid; /* id of this connection for stats*/
288 int c_opsinitiated; /* # ops initiated/next op id */
289 int c_opscompleted; /* # ops completed */
292 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
293 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
295 if ( ldap_debug & level ) \
296 fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
297 if ( ldap_syslog & level ) \
298 syslog( ldap_syslog_level, fmt, connid, opid, arg1, \
302 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
305 #include "proto-slap.h"
309 #endif /* _slap_h_ */