]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
17441a8b01b66e55a2e1dacbd5747063210d42ee
[openldap] / servers / slapd / back-monitor / back-monitor.h
1 /* back-monitor.h - ldap monitor back-end header file */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
8  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9  * 
10  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
11  * 
12  * This work has beed deveolped for the OpenLDAP Foundation 
13  * in the hope that it may be useful to the Open Source community, 
14  * but WITHOUT ANY WARRANTY.
15  * 
16  * Permission is granted to anyone to use this software for any purpose
17  * on any computer system, and to alter it and redistribute it, subject
18  * to the following restrictions:
19  * 
20  * 1. The author and SysNet s.n.c. are not responsible for the consequences
21  *    of use of this software, no matter how awful, even if they arise from
22  *    flaws in it.
23  * 
24  * 2. The origin of this software must not be misrepresented, either by
25  *    explicit claim or by omission.  Since few users ever read sources,
26  *    credits should appear in the documentation.
27  * 
28  * 3. Altered versions must be plainly marked as such, and must not be
29  *    misrepresented as being the original software.  Since few users
30  *    ever read sources, credits should appear in the documentation.
31  *    SysNet s.n.c. cannot be responsible for the consequences of the
32  *    alterations.
33  * 
34  * 4. This notice may not be removed or altered.
35  */
36
37 #ifndef _BACK_MONITOR_H_
38 #define _BACK_MONITOR_H_
39
40 #include <slap.h>
41 #include <avl.h>
42 #include <ldap_pvt.h>
43 #include <ldap_pvt_thread.h>
44
45 LDAP_BEGIN_DECL
46
47 /*
48  * The cache maps DNs to Entries.
49  * Each entry, on turn, holds the list of its children in the e_private field.
50  * This is used by search operation to perform onelevel and subtree candidate
51  * selection.
52  */
53 struct monitorcache {
54         char                    *mc_ndn;
55         Entry                   *mc_e;
56 };
57
58 struct monitorentrypriv {
59         ldap_pvt_thread_mutex_t mp_mutex;       /* entry mutex */
60         Entry                   *mp_next;       /* pointer to next sibling */
61         Entry                   *mp_children;   /* pointer to first child */
62         struct monitorsubsys    *mp_info;       /* subsystem info */
63 #define mp_type         mp_info->mss_type
64         int                     mp_flags;       /* flags */
65
66 #define MONITOR_F_NONE          0x00
67 #define MONITOR_F_SUB           0x01            /* subentry of subsystem */
68 #define MONITOR_F_PERSISTENT    0x10            /* persistent entry */
69 #define MONITOR_F_PERSISTENT_CH 0x20            /* subsystem generates 
70                                                    persistent entries */
71 #define MONITOR_F_VOLATILE      0x40            /* volatile entry */
72 #define MONITOR_F_VOLATILE_CH   0x80            /* subsystem generates 
73                                                    volatile entries */
74 };
75
76 struct monitorinfo {
77         Avlnode                 *mi_cache;
78         ldap_pvt_thread_mutex_t mi_cache_mutex;
79 };
80
81 /*
82  * DNs
83  */
84 #define SLAPD_MONITOR_LISTENER          0
85 #define SLAPD_MONITOR_LISTENER_NAME     "Listener"
86 #define SLAPD_MONITOR_LISTENER_RDN      \
87         "cn=" SLAPD_MONITOR_LISTENER_NAME
88 #define SLAPD_MONITOR_LISTENER_DN       \
89         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
90
91 #define SLAPD_MONITOR_DATABASE          1
92 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
93 #define SLAPD_MONITOR_DATABASE_RDN      \
94         "cn=" SLAPD_MONITOR_DATABASE_NAME
95 #define SLAPD_MONITOR_DATABASE_DN       \
96         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
97
98 #define SLAPD_MONITOR_BACKEND           2
99 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
100 #define SLAPD_MONITOR_BACKEND_RDN       \
101         "cn=" SLAPD_MONITOR_BACKEND_NAME
102 #define SLAPD_MONITOR_BACKEND_DN        \
103         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
104
105 #define SLAPD_MONITOR_THREAD            3
106 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
107 #define SLAPD_MONITOR_THREAD_RDN        \
108         "cn=" SLAPD_MONITOR_THREAD_NAME
109 #define SLAPD_MONITOR_THREAD_DN \
110         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
111
112 #define SLAPD_MONITOR_SASL              4
113 #define SLAPD_MONITOR_SASL_NAME         "SASL"
114 #define SLAPD_MONITOR_SASL_RDN  \
115         "cn=" SLAPD_MONITOR_SASL_NAME
116 #define SLAPD_MONITOR_SASL_DN   \
117         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
118
119 #define SLAPD_MONITOR_TLS               5
120 #define SLAPD_MONITOR_TLS_NAME          "TLS"
121 #define SLAPD_MONITOR_TLS_RDN   \
122         "cn=" SLAPD_MONITOR_TLS_NAME
123 #define SLAPD_MONITOR_TLS_DN    \
124         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
125
126 #define SLAPD_MONITOR_CONN              6
127 #define SLAPD_MONITOR_CONN_NAME         "Connections"
128 #define SLAPD_MONITOR_CONN_RDN  \
129         "cn=" SLAPD_MONITOR_CONN_NAME
130 #define SLAPD_MONITOR_CONN_DN   \
131         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
132
133 #define SLAPD_MONITOR_READW             7
134 #define SLAPD_MONITOR_READW_NAME        "Read Waiters"
135 #define SLAPD_MONITOR_READW_RDN \
136         "cn=" SLAPD_MONITOR_READW_NAME
137 #define SLAPD_MONITOR_READW_DN  \
138         SLAPD_MONITOR_READW_RDN "," SLAPD_MONITOR_DN
139
140 #define SLAPD_MONITOR_WRITEW            8
141 #define SLAPD_MONITOR_WRITEW_NAME       "Write Waiters"
142 #define SLAPD_MONITOR_WRITEW_RDN        \
143         "cn=" SLAPD_MONITOR_WRITEW_NAME
144 #define SLAPD_MONITOR_WRITEW_DN \
145         SLAPD_MONITOR_WRITEW_RDN "," SLAPD_MONITOR_DN
146
147 #define SLAPD_MONITOR_LOG               9
148 #define SLAPD_MONITOR_LOG_NAME          "Log"
149 #define SLAPD_MONITOR_LOG_RDN   \
150         "cn=" SLAPD_MONITOR_LOG_NAME
151 #define SLAPD_MONITOR_LOG_DN    \
152         SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
153
154 #define SLAPD_MONITOR_OPS               10
155 #define SLAPD_MONITOR_OPS_NAME          "Operations"
156 #define SLAPD_MONITOR_OPS_RDN   \
157         "cn=" SLAPD_MONITOR_OPS_NAME
158 #define SLAPD_MONITOR_OPS_DN    \
159         SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
160
161 #define SLAPD_MONITOR_SENT              11
162 #define SLAPD_MONITOR_SENT_NAME         "Sent"
163 #define SLAPD_MONITOR_SENT_RDN  \
164         "cn=" SLAPD_MONITOR_SENT_NAME
165 #define SLAPD_MONITOR_SENT_DN   \
166         SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
167
168 struct monitorsubsys {
169         int             mss_type;
170         char            *mss_name;
171         char            *mss_rdn;
172         char            *mss_dn;
173         char            *mss_ndn;
174         int             mss_flags;
175
176 #define MONITOR_HAS_VOLATILE_CH( mp ) \
177         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
178 #define MONITOR_HAS_CHILDREN( mp ) \
179         ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
180
181         /* initialize entry and subentries */
182         int             ( *mss_init )( BackendDB * );
183         /* update existing dynamic entry and subentries */
184         int             ( *mss_update )( struct monitorinfo *, Entry * );
185         /* create new dynamic subentries */
186         int             ( *mss_create )( struct monitorinfo *, const char *ndn, 
187                                 Entry *, Entry ** );
188         /* modify entry and subentries */
189         int             ( *mss_modify )( struct monitorinfo *, Entry *, 
190                                 Modifications *modlist );
191 };
192
193 extern struct monitorsubsys monitor_subsys[];
194
195 extern AttributeDescription *monitor_ad_desc;
196
197 /*
198  * cache
199  */
200
201 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
202 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
203 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
204 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry **ep ));
205 extern int monitor_cache_dn2entry LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry **ep, Entry **matched ));
206 extern int monitor_cache_lock LDAP_P(( Entry *e ));
207 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
208
209 /*
210  * update
211  */
212
213 extern int monitor_entry_update LDAP_P(( struct monitorinfo *mi, Entry *e ));
214 extern int monitor_entry_create LDAP_P(( struct monitorinfo *mi, const char *ndn, Entry *e_parent, Entry **ep ));
215 extern int monitor_entry_modify LDAP_P(( struct monitorinfo *mi, Entry *e, Modifications *modlist ));
216
217 LDAP_END_DECL
218
219 #include "proto-back-monitor.h"
220
221 #endif /* _back_monitor_h_ */
222