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