]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
5db9355f013628df869c5b1b94c5f7c5777f84ca
[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         Avlnode                 *mi_cache;
75         ldap_pvt_thread_mutex_t mi_cache_mutex;
76
77         ObjectClass *monitor_oc_monitorServer;
78         ObjectClass *monitor_oc_monitorContainer;
79         ObjectClass *monitor_oc_monitorCounter;
80         ObjectClass *monitor_oc_monitorOperation;
81         ObjectClass *monitor_oc_monitorConnection;
82         ObjectClass *monitor_oc_managedObject;
83         ObjectClass *monitor_oc_monitoredObject;
84
85         AttributeDescription *monitor_ad_monitoredInfo;
86         AttributeDescription *monitor_ad_managedInfo;
87         AttributeDescription *monitor_ad_monitorCounter;
88         AttributeDescription *monitor_ad_monitorOpCompleted;
89         AttributeDescription *monitor_ad_monitorOpInitiated;
90         AttributeDescription *monitor_ad_monitorConnectionNumber;
91         AttributeDescription *monitor_ad_monitorConnectionAuthzDN;
92         AttributeDescription *monitor_ad_monitorConnectionLocalAddress;
93         AttributeDescription *monitor_ad_monitorConnectionPeerAddress;
94
95         AttributeDescription *monitor_ad_description;
96 };
97
98 /*
99  * DNs
100  */
101 #define SLAPD_MONITOR_LISTENER          0
102 #define SLAPD_MONITOR_LISTENER_NAME     "Listeners"
103 #define SLAPD_MONITOR_LISTENER_RDN      \
104         "cn=" SLAPD_MONITOR_LISTENER_NAME
105 #define SLAPD_MONITOR_LISTENER_DN       \
106         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
107
108 #define SLAPD_MONITOR_DATABASE          1
109 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
110 #define SLAPD_MONITOR_DATABASE_RDN      \
111         "cn=" SLAPD_MONITOR_DATABASE_NAME
112 #define SLAPD_MONITOR_DATABASE_DN       \
113         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
114
115 #define SLAPD_MONITOR_BACKEND           2
116 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
117 #define SLAPD_MONITOR_BACKEND_RDN       \
118         "cn=" SLAPD_MONITOR_BACKEND_NAME
119 #define SLAPD_MONITOR_BACKEND_DN        \
120         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
121
122 #define SLAPD_MONITOR_THREAD            3
123 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
124 #define SLAPD_MONITOR_THREAD_RDN        \
125         "cn=" SLAPD_MONITOR_THREAD_NAME
126 #define SLAPD_MONITOR_THREAD_DN \
127         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
128
129 #define SLAPD_MONITOR_SASL              4
130 #define SLAPD_MONITOR_SASL_NAME         "SASL"
131 #define SLAPD_MONITOR_SASL_RDN  \
132         "cn=" SLAPD_MONITOR_SASL_NAME
133 #define SLAPD_MONITOR_SASL_DN   \
134         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
135
136 #define SLAPD_MONITOR_TLS               5
137 #define SLAPD_MONITOR_TLS_NAME          "TLS"
138 #define SLAPD_MONITOR_TLS_RDN   \
139         "cn=" SLAPD_MONITOR_TLS_NAME
140 #define SLAPD_MONITOR_TLS_DN    \
141         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
142
143 #define SLAPD_MONITOR_CONN              6
144 #define SLAPD_MONITOR_CONN_NAME         "Connections"
145 #define SLAPD_MONITOR_CONN_RDN  \
146         "cn=" SLAPD_MONITOR_CONN_NAME
147 #define SLAPD_MONITOR_CONN_DN   \
148         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
149
150 #define SLAPD_MONITOR_READW             7
151 #define SLAPD_MONITOR_READW_NAME        "Read Waiters"
152 #define SLAPD_MONITOR_READW_RDN \
153         "cn=" SLAPD_MONITOR_READW_NAME
154 #define SLAPD_MONITOR_READW_DN  \
155         SLAPD_MONITOR_READW_RDN "," SLAPD_MONITOR_DN
156
157 #define SLAPD_MONITOR_WRITEW            8
158 #define SLAPD_MONITOR_WRITEW_NAME       "Write Waiters"
159 #define SLAPD_MONITOR_WRITEW_RDN        \
160         "cn=" SLAPD_MONITOR_WRITEW_NAME
161 #define SLAPD_MONITOR_WRITEW_DN \
162         SLAPD_MONITOR_WRITEW_RDN "," SLAPD_MONITOR_DN
163
164 #define SLAPD_MONITOR_LOG               9
165 #define SLAPD_MONITOR_LOG_NAME          "Log"
166 #define SLAPD_MONITOR_LOG_RDN   \
167         "cn=" SLAPD_MONITOR_LOG_NAME
168 #define SLAPD_MONITOR_LOG_DN    \
169         SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
170
171 #define SLAPD_MONITOR_OPS               10
172 #define SLAPD_MONITOR_OPS_NAME          "Operations"
173 #define SLAPD_MONITOR_OPS_RDN   \
174         "cn=" SLAPD_MONITOR_OPS_NAME
175 #define SLAPD_MONITOR_OPS_DN    \
176         SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
177
178 #define SLAPD_MONITOR_SENT              11
179 #define SLAPD_MONITOR_SENT_NAME         "Statistics"
180 #define SLAPD_MONITOR_SENT_RDN  \
181         "cn=" SLAPD_MONITOR_SENT_NAME
182 #define SLAPD_MONITOR_SENT_DN   \
183         SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
184
185 #define SLAPD_MONITOR_TIME              12
186 #define SLAPD_MONITOR_TIME_NAME         "Time"
187 #define SLAPD_MONITOR_TIME_RDN  \
188         "cn=" SLAPD_MONITOR_TIME_NAME
189 #define SLAPD_MONITOR_TIME_DN   \
190         SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
191
192 #define SLAPD_MONITOR_OBJECTCLASSES \
193         "objectClass: top\n" \
194         "objectClass: monitor\n" \
195         "objectClass: extensibleObject\n" \
196         "structuralObjectClass: monitor\n"
197
198 struct monitorsubsys {
199         int             mss_type;
200         char            *mss_name;
201         struct berval   mss_rdn;
202         struct berval   mss_dn;
203         struct berval   mss_ndn;
204         int             mss_flags;
205
206 #define MONITOR_HAS_VOLATILE_CH( mp ) \
207         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
208 #define MONITOR_HAS_CHILDREN( mp ) \
209         ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
210
211         /* initialize entry and subentries */
212         int             ( *mss_init )( BackendDB * );
213         /* update existing dynamic entry and subentries */
214         int             ( *mss_update )( Operation *, Entry * );
215         /* create new dynamic subentries */
216         int             ( *mss_create )( Operation *,
217                                 struct berval *ndn, Entry *, Entry ** );
218         /* modify entry and subentries */
219         int             ( *mss_modify )( Operation *, Entry * );
220 };
221
222 extern struct monitorsubsys monitor_subsys[];
223
224 extern BackendDB *be_monitor;
225
226 /*
227  * cache
228  */
229
230 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
231 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
232 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
233 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep ));
234 extern int monitor_cache_dn2entry LDAP_P(( Operation *op, struct berval *ndn, Entry **ep, Entry **matched ));
235 extern int monitor_cache_lock LDAP_P(( Entry *e ));
236 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
237
238 /*
239  * update
240  */
241
242 extern int monitor_entry_update LDAP_P(( Operation *op, Entry *e ));
243 extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn,
244                 Entry *e_parent, Entry **ep ));
245 extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e ));
246
247 LDAP_END_DECL
248
249 #include "proto-back-monitor.h"
250
251 #endif /* _back_monitor_h_ */
252