]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/back-monitor.h
Fix prev commit
[openldap] / servers / slapd / back-monitor / back-monitor.h
1 /* back-monitor.h - ldap monitor back-end header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2001-2004 The OpenLDAP Foundation.
6  * Portions Copyright 2001-2003 Pierangelo Masarati.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was initially developed by Pierangelo Masarati for inclusion
19  * in OpenLDAP Software.
20  */
21
22 #ifndef _BACK_MONITOR_H_
23 #define _BACK_MONITOR_H_
24
25 #include <ldap_pvt.h>
26 #include <ldap_pvt_thread.h>
27 #include <avl.h>
28 #include <slap.h>
29
30 LDAP_BEGIN_DECL
31
32 /*
33  * The cache maps DNs to Entries.
34  * Each entry, on turn, holds the list of its children in the e_private field.
35  * This is used by search operation to perform onelevel and subtree candidate
36  * selection.
37  */
38 struct monitorcache {
39         struct berval           mc_ndn;
40         Entry                   *mc_e;
41 };
42
43 struct monitorentrypriv {
44         ldap_pvt_thread_mutex_t mp_mutex;       /* entry mutex */
45         Entry                   *mp_next;       /* pointer to next sibling */
46         Entry                   *mp_children;   /* pointer to first child */
47         struct monitorsubsys    *mp_info;       /* subsystem info */
48 #define mp_type         mp_info->mss_type
49         int                     mp_flags;       /* flags */
50
51 #define MONITOR_F_NONE          0x00
52 #define MONITOR_F_SUB           0x01            /* subentry of subsystem */
53 #define MONITOR_F_PERSISTENT    0x10            /* persistent entry */
54 #define MONITOR_F_PERSISTENT_CH 0x20            /* subsystem generates 
55                                                    persistent entries */
56 #define MONITOR_F_VOLATILE      0x40            /* volatile entry */
57 #define MONITOR_F_VOLATILE_CH   0x80            /* subsystem generates 
58                                                    volatile entries */
59 };
60
61 struct monitorinfo {
62
63         /*
64          * Internal data
65          */
66         Avlnode                 *mi_cache;
67         ldap_pvt_thread_mutex_t mi_cache_mutex;
68
69         /*
70          * Config parameters
71          */
72         struct berval           mi_l;
73         struct berval           mi_startTime;   /* don't free it */
74
75         /*
76          * Specific schema entities
77          */
78         ObjectClass *mi_oc_monitor;
79         ObjectClass *mi_oc_monitorServer;
80         ObjectClass *mi_oc_monitorContainer;
81         ObjectClass *mi_oc_monitorCounterObject;
82         ObjectClass *mi_oc_monitorOperation;
83         ObjectClass *mi_oc_monitorConnection;
84         ObjectClass *mi_oc_managedObject;
85         ObjectClass *mi_oc_monitoredObject;
86
87         AttributeDescription *mi_ad_monitoredInfo;
88         AttributeDescription *mi_ad_managedInfo;
89         AttributeDescription *mi_ad_monitorCounter;
90         AttributeDescription *mi_ad_monitorOpCompleted;
91         AttributeDescription *mi_ad_monitorOpInitiated;
92         AttributeDescription *mi_ad_monitorConnectionNumber;
93         AttributeDescription *mi_ad_monitorConnectionAuthzDN;
94         AttributeDescription *mi_ad_monitorConnectionLocalAddress;
95         AttributeDescription *mi_ad_monitorConnectionPeerAddress;
96         AttributeDescription *mi_ad_monitorTimestamp;
97         AttributeDescription *mi_ad_monitorOverlay;
98
99         /*
100          * Generic description attribute
101          */
102         AttributeDescription *mi_ad_description;
103         AttributeDescription *mi_ad_seeAlso;
104         AttributeDescription *mi_ad_l;
105 };
106
107 /*
108  * DNs
109  */
110 #define SLAPD_MONITOR_LISTENER          0
111 #define SLAPD_MONITOR_LISTENER_NAME     "Listeners"
112 #define SLAPD_MONITOR_LISTENER_RDN      \
113         "cn=" SLAPD_MONITOR_LISTENER_NAME
114 #define SLAPD_MONITOR_LISTENER_DN       \
115         SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
116
117 #define SLAPD_MONITOR_DATABASE          1
118 #define SLAPD_MONITOR_DATABASE_NAME     "Databases"
119 #define SLAPD_MONITOR_DATABASE_RDN      \
120         "cn=" SLAPD_MONITOR_DATABASE_NAME
121 #define SLAPD_MONITOR_DATABASE_DN       \
122         SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
123
124 #define SLAPD_MONITOR_BACKEND           2
125 #define SLAPD_MONITOR_BACKEND_NAME      "Backends"
126 #define SLAPD_MONITOR_BACKEND_RDN       \
127         "cn=" SLAPD_MONITOR_BACKEND_NAME
128 #define SLAPD_MONITOR_BACKEND_DN        \
129         SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
130
131 #define SLAPD_MONITOR_THREAD            3
132 #define SLAPD_MONITOR_THREAD_NAME       "Threads"
133 #define SLAPD_MONITOR_THREAD_RDN        \
134         "cn=" SLAPD_MONITOR_THREAD_NAME
135 #define SLAPD_MONITOR_THREAD_DN \
136         SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
137
138 #define SLAPD_MONITOR_SASL              4
139 #define SLAPD_MONITOR_SASL_NAME         "SASL"
140 #define SLAPD_MONITOR_SASL_RDN  \
141         "cn=" SLAPD_MONITOR_SASL_NAME
142 #define SLAPD_MONITOR_SASL_DN   \
143         SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
144
145 #define SLAPD_MONITOR_TLS               5
146 #define SLAPD_MONITOR_TLS_NAME          "TLS"
147 #define SLAPD_MONITOR_TLS_RDN   \
148         "cn=" SLAPD_MONITOR_TLS_NAME
149 #define SLAPD_MONITOR_TLS_DN    \
150         SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
151
152 #define SLAPD_MONITOR_CONN              6
153 #define SLAPD_MONITOR_CONN_NAME         "Connections"
154 #define SLAPD_MONITOR_CONN_RDN  \
155         "cn=" SLAPD_MONITOR_CONN_NAME
156 #define SLAPD_MONITOR_CONN_DN   \
157         SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
158
159 #define SLAPD_MONITOR_RWW               7
160 #define SLAPD_MONITOR_RWW_NAME  "Waiters"
161 #define SLAPD_MONITOR_RWW_RDN   \
162         "cn=" SLAPD_MONITOR_RWW_NAME
163 #define SLAPD_MONITOR_RWW_DN    \
164         SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
165
166 #define SLAPD_MONITOR_LOG               8
167 #define SLAPD_MONITOR_LOG_NAME          "Log"
168 #define SLAPD_MONITOR_LOG_RDN   \
169         "cn=" SLAPD_MONITOR_LOG_NAME
170 #define SLAPD_MONITOR_LOG_DN    \
171         SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
172
173 #define SLAPD_MONITOR_OPS               9
174 #define SLAPD_MONITOR_OPS_NAME          "Operations"
175 #define SLAPD_MONITOR_OPS_RDN   \
176         "cn=" SLAPD_MONITOR_OPS_NAME
177 #define SLAPD_MONITOR_OPS_DN    \
178         SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
179
180 #define SLAPD_MONITOR_SENT              10
181 #define SLAPD_MONITOR_SENT_NAME         "Statistics"
182 #define SLAPD_MONITOR_SENT_RDN  \
183         "cn=" SLAPD_MONITOR_SENT_NAME
184 #define SLAPD_MONITOR_SENT_DN   \
185         SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
186
187 #define SLAPD_MONITOR_TIME              11
188 #define SLAPD_MONITOR_TIME_NAME         "Time"
189 #define SLAPD_MONITOR_TIME_RDN  \
190         "cn=" SLAPD_MONITOR_TIME_NAME
191 #define SLAPD_MONITOR_TIME_DN   \
192         SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
193
194 struct monitorsubsys {
195         int             mss_type;
196         char            *mss_name;
197         struct berval   mss_rdn;
198         struct berval   mss_dn;
199         struct berval   mss_ndn;
200         int             mss_flags;
201
202 #define MONITOR_HAS_VOLATILE_CH( mp ) \
203         ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
204 #define MONITOR_HAS_CHILDREN( mp ) \
205         ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
206
207         /* initialize entry and subentries */
208         int             ( *mss_init )( BackendDB * );
209         /* update existing dynamic entry and subentries */
210         int             ( *mss_update )( Operation *, Entry * );
211         /* create new dynamic subentries */
212         int             ( *mss_create )( Operation *,
213                                 struct berval *ndn, Entry *, Entry ** );
214         /* modify entry and subentries */
215         int             ( *mss_modify )( Operation *, Entry * );
216 };
217
218 extern struct monitorsubsys monitor_subsys[];
219
220 extern BackendDB *be_monitor;
221
222 /* increase this bufsize if entries in string form get too big */
223 #define BACKMONITOR_BUFSIZE     1024
224
225 /*
226  * cache
227  */
228
229 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
230 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
231 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
232 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep ));
233 extern int monitor_cache_dn2entry LDAP_P(( Operation *op, struct berval *ndn, Entry **ep, Entry **matched ));
234 extern int monitor_cache_lock LDAP_P(( Entry *e ));
235 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
236
237 /*
238  * update
239  */
240
241 extern int monitor_entry_update LDAP_P(( Operation *op, Entry *e ));
242 extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn,
243                 Entry *e_parent, Entry **ep ));
244 extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e ));
245
246 LDAP_END_DECL
247
248 #include "proto-back-monitor.h"
249
250 #endif /* _back_monitor_h_ */
251