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