]> git.sur5r.net Git - openldap/blob - servers/slapd/slap.h
fix SIGUNUSED typo
[openldap] / servers / slapd / slap.h
1 /* slap.h - stand alone ldap server include file */
2
3 #ifndef _SLDAPD_H_
4 #define _SLDAPD_H_
5
6 #define LDAP_SYSLOG
7
8 #include <syslog.h>
9 #include "avl.h"
10 #include "lber.h"
11 #include "ldap.h"
12 #include "lthread.h"
13 #include "ldif.h"
14
15 #define DN_DNS  0
16 #define DN_X500 1
17
18 #define ON      1
19 #define OFF     (-1)
20
21 /*
22  * represents an attribute value assertion (i.e., attr=value)
23  */
24 typedef struct ava {
25         char            *ava_type;
26         struct berval   ava_value;
27 } Ava;
28
29 /*
30  * represents a search filter
31  */
32 typedef struct filter {
33         unsigned long   f_choice;       /* values taken from ldap.h */
34
35         union {
36                 /* present */
37                 char            *f_un_type;
38
39                 /* equality, lessorequal, greaterorequal, approx */
40                 Ava             f_un_ava;
41
42                 /* and, or, not */
43                 struct filter   *f_un_complex;
44
45                 /* substrings */
46                 struct sub {
47                         char    *f_un_sub_type;
48                         char    *f_un_sub_initial;
49                         char    **f_un_sub_any;
50                         char    *f_un_sub_final;
51                 } f_un_sub;
52         } f_un;
53 #define f_type          f_un.f_un_type
54 #define f_ava           f_un.f_un_ava
55 #define f_avtype        f_un.f_un_ava.ava_type
56 #define f_avvalue       f_un.f_un_ava.ava_value
57 #define f_and           f_un.f_un_complex
58 #define f_or            f_un.f_un_complex
59 #define f_not           f_un.f_un_complex
60 #define f_list          f_un.f_un_complex
61 #define f_sub           f_un.f_un_sub
62 #define f_sub_type      f_un.f_un_sub.f_un_sub_type
63 #define f_sub_initial   f_un.f_un_sub.f_un_sub_initial
64 #define f_sub_any       f_un.f_un_sub.f_un_sub_any
65 #define f_sub_final     f_un.f_un_sub.f_un_sub_final
66
67         struct filter   *f_next;
68 } Filter;
69
70 /*
71  * represents an attribute (type + values + syntax)
72  */
73 typedef struct attr {
74         char            *a_type;
75         struct berval   **a_vals;
76         int             a_syntax;
77         struct attr     *a_next;
78 } Attribute;
79
80 /*
81  * the attr_syntax() routine returns one of these values
82  * telling what kind of syntax an attribute supports.
83  */
84 #define SYNTAX_CIS      0x01    /* case insensitive string              */
85 #define SYNTAX_CES      0x02    /* case sensitive string                */
86 #define SYNTAX_BIN      0x04    /* binary data                          */
87 #define SYNTAX_TEL      0x08    /* telephone number string              */
88 #define SYNTAX_DN       0x10    /* dn string                            */
89
90 /*
91  * the id used in the indexes to refer to an entry
92  */
93 typedef unsigned long   ID;
94 #define NOID    ((unsigned long)-1)
95
96 /*
97  * represents an entry in core
98  */
99 typedef struct entry {
100         char            *e_dn;          /* DN of this entry               */
101         Attribute       *e_attrs;       /* list of attributes + values    */
102
103         ID              e_id;           /* id of this entry - this should */
104                                         /* really be private to back-ldbm */
105         char            e_state;        /* for the cache                  */
106 #define ENTRY_STATE_DELETED     1
107 #define ENTRY_STATE_CREATING    2
108         int             e_refcnt;       /* # threads ref'ing this entry   */
109         struct entry    *e_lrunext;     /* for cache lru list             */
110         struct entry    *e_lruprev;
111 } Entry;
112
113 /*
114  * represents an access control list
115  */
116
117 /* the "by" part */
118 struct access {
119         char            *a_dnpat;
120         char            *a_addrpat;
121         char            *a_domainpat;
122         char            *a_dnattr;
123         long            a_access;
124 #define ACL_NONE        0x01
125 #define ACL_COMPARE     0x02
126 #define ACL_SEARCH      0x04
127 #define ACL_READ        0x08
128 #define ACL_WRITE       0x10
129 #define ACL_SELF        0x40
130         struct access   *a_next;
131 };
132
133 /* the "to" part */
134 struct acl {
135         /* "to" part: the entries this acl applies to */
136         Filter          *acl_filter;
137         char            *acl_dnpat;
138         char            **acl_attrs;
139
140         /* "by" part: list of who has what access to the entries */
141         struct access   *acl_access;
142
143         struct acl      *acl_next;
144 };
145
146 /*
147  * represents schema information for a database
148  */
149
150 struct objclass {
151         char            *oc_name;
152         char            **oc_required;
153         char            **oc_allowed;
154         struct objclass *oc_next;
155 };
156
157 /*
158  * represents a "database"
159  */
160
161 typedef struct backend {
162         char    **be_suffix;    /* the DN suffixes of data in this backend */
163         char    *be_rootdn;     /* the magic "root" dn for this db         */
164         char    *be_rootpw;     /* the magic "root" password for this db   */
165         int     be_readonly;    /* 1 => db is in "read only" mode          */
166         int     be_sizelimit;   /* size limit for this backend             */
167         int     be_timelimit;   /* time limit for this backend             */
168         struct acl *be_acl;     /* access control list for this backend    */
169         int     be_dfltaccess;  /* access given if no acl matches          */
170         char    **be_replica;   /* replicas of this backend (in master)    */
171         char    *be_replogfile; /* replication log file (in master)        */
172         char    *be_updatedn;   /* allowed to make changes (in replicas)   */
173         int     be_lastmod;     /* keep track of lastmodified{by,time}     */
174         char    *be_type;       /* type of database                        */
175
176         void    *be_private;    /* anything the backend needs              */
177
178         IFP     be_bind;        /* backend bind routine                    */
179         IFP     be_unbind;      /* backend unbind routine                  */
180         IFP     be_search;      /* backend search routine                  */
181         IFP     be_compare;     /* backend compare routine                 */
182         IFP     be_modify;      /* backend modify routine                  */
183         IFP     be_modrdn;      /* backend modrdn routine                  */
184         IFP     be_add;         /* backend add routine                     */
185         IFP     be_delete;      /* backend delete routine                  */
186         IFP     be_abandon;     /* backend abandon routine                 */
187         IFP     be_config;      /* backend config routine                  */
188         IFP     be_init;        /* backend init routine                    */
189         IFP     be_close;       /* backend close routine                   */
190 } Backend;
191
192 /*
193  * represents an operation pending from an ldap client
194  */
195
196 typedef struct op {
197         BerElement      *o_ber;         /* ber of the request             */
198         long            o_msgid;        /* msgid of the request           */
199         unsigned long   o_tag;          /* tag of the request             */
200         time_t          o_time;         /* time op was initiated          */
201         char            *o_dn;          /* dn bound when op was initiated */
202         int             o_authtype;     /* auth method used to bind dn    */
203                                         /* values taken from ldap.h       */
204                                         /* LDAP_AUTH_*                    */
205         int             o_opid;         /* id of this operation           */
206         int             o_connid;       /* id of conn initiating this op  */
207 #ifdef CLDAP
208         int             o_cldap;        /* != 0 if this came in via CLDAP */
209         struct sockaddr o_clientaddr;   /* client address if via CLDAP    */
210         char            o_searchbase;   /* search base if via CLDAP       */
211 #endif
212         struct op       *o_next;        /* next operation pending         */
213         pthread_t       o_tid;          /* thread handling this op        */
214         int             o_abandon;      /* signals op has been abandoned  */
215         pthread_mutex_t o_abandonmutex; /* signals op has been abandoned  */
216
217         int             o_private;      /* anything the backend needs     */
218 } Operation;
219
220 /*
221  * represents a connection from an ldap client
222  */
223
224 typedef struct conn {
225         Sockbuf         c_sb;           /* ber connection stuff           */
226         char            *c_dn;          /* current DN bound to this conn  */
227         pthread_mutex_t c_dnmutex;      /* mutex for c_dn field           */
228         int             c_authtype;     /* auth method used to bind c_dn  */
229 #ifdef COMPAT
230         int             c_version;      /* for compatibility w/2.0, 3.0   */
231 #endif
232         char            *c_addr;        /* address of client on this conn */
233         char            *c_domain;      /* domain of client on this conn  */
234         Operation       *c_ops;         /* list of pending operations     */
235         pthread_mutex_t c_opsmutex;     /* mutex for c_ops list & stats   */
236         pthread_mutex_t c_pdumutex;     /* only one pdu written at a time */
237         pthread_cond_t  c_wcv;          /* used to wait for sd write-ready*/
238         int             c_gettingber;   /* in the middle of ber_get_next  */
239         BerElement      *c_currentber;  /* ber we're getting              */
240         int             c_writewaiter;  /* signals write-ready sd waiter  */
241         int             c_pduwaiters;   /* signals threads waiting 4 pdu  */
242         time_t          c_starttime;    /* when the connection was opened */
243         int             c_connid;       /* id of this connection for stats*/
244         int             c_opsinitiated; /* # ops initiated/next op id     */
245         int             c_opscompleted; /* # ops completed                */
246 } Connection;
247
248 #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)
249 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )  \
250         { \
251                 if ( ldap_debug & level ) \
252                         fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
253                 if ( ldap_syslog & level ) \
254                         syslog( ldap_syslog_level, fmt, connid, opid, arg1, \
255                             arg2, arg3 ); \
256         }
257 #else
258 #define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 )
259 #endif
260
261 #ifdef NEEDPROTOS
262 #include "proto-slap.h"
263 #endif
264
265 #endif /* _slap_h_ */