1 /* back-monitor.h - ldap monitor back-end header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2006 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
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>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
22 #ifndef _BACK_MONITOR_H_
23 #define _BACK_MONITOR_H_
26 #include <ldap_pvt_thread.h>
32 /* define if si_ad_labeledURI is removed from slap_schema */
33 #undef MONITOR_DEFINE_LABELEDURI
35 typedef struct monitor_callback_t {
36 int (*mc_update)( Operation *op, SlapReply *rs, Entry *e, void *priv );
38 for user-defined entries */
39 int (*mc_modify)( Operation *op, SlapReply *rs, Entry *e, void *priv );
41 for user-defined entries */
42 int (*mc_free)( Entry *e, void *priv );
44 for user-defined entries */
45 void *mc_private; /* opaque pointer to
47 struct monitor_callback_t *mc_next;
51 typedef struct monitor_entry_t {
52 ldap_pvt_thread_mutex_t mp_mutex; /* entry mutex */
53 Entry *mp_next; /* pointer to next sibling */
54 Entry *mp_children; /* pointer to first child */
55 struct monitor_subsys_t *mp_info; /* subsystem info */
56 #define mp_type mp_info->mss_type
57 unsigned long mp_flags; /* flags */
59 #define MONITOR_F_NONE 0x0000U
60 #define MONITOR_F_SUB 0x0001U /* subentry of subsystem */
61 #define MONITOR_F_PERSISTENT 0x0010U /* persistent entry */
62 #define MONITOR_F_PERSISTENT_CH 0x0020U /* subsystem generates
64 #define MONITOR_F_VOLATILE 0x0040U /* volatile entry */
65 #define MONITOR_F_VOLATILE_CH 0x0080U /* subsystem generates
67 #define MONITOR_F_EXTERNAL 0x0100U /* externally added - don't free */
68 /* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */
70 struct monitor_callback_t *mp_cb; /* callback sequence */
73 typedef struct monitor_info_t {
79 ldap_pvt_thread_mutex_t mi_cache_mutex;
84 struct berval mi_startTime; /* don't free it! */
85 struct berval mi_creatorsName; /* don't free it! */
86 struct berval mi_ncreatorsName; /* don't free it! */
89 * Specific schema entities
91 ObjectClass *mi_oc_monitor;
92 ObjectClass *mi_oc_monitorServer;
93 ObjectClass *mi_oc_monitorContainer;
94 ObjectClass *mi_oc_monitorCounterObject;
95 ObjectClass *mi_oc_monitorOperation;
96 ObjectClass *mi_oc_monitorConnection;
97 ObjectClass *mi_oc_managedObject;
98 ObjectClass *mi_oc_monitoredObject;
100 AttributeDescription *mi_ad_monitoredInfo;
101 AttributeDescription *mi_ad_managedInfo;
102 AttributeDescription *mi_ad_monitorCounter;
103 AttributeDescription *mi_ad_monitorOpCompleted;
104 AttributeDescription *mi_ad_monitorOpInitiated;
105 AttributeDescription *mi_ad_monitorConnectionNumber;
106 AttributeDescription *mi_ad_monitorConnectionAuthzDN;
107 AttributeDescription *mi_ad_monitorConnectionLocalAddress;
108 AttributeDescription *mi_ad_monitorConnectionPeerAddress;
109 AttributeDescription *mi_ad_monitorTimestamp;
110 AttributeDescription *mi_ad_monitorOverlay;
111 AttributeDescription *mi_ad_monitorConnectionProtocol;
112 AttributeDescription *mi_ad_monitorConnectionOpsReceived;
113 AttributeDescription *mi_ad_monitorConnectionOpsExecuting;
114 AttributeDescription *mi_ad_monitorConnectionOpsPending;
115 AttributeDescription *mi_ad_monitorConnectionOpsCompleted;
116 AttributeDescription *mi_ad_monitorConnectionGet;
117 AttributeDescription *mi_ad_monitorConnectionRead;
118 AttributeDescription *mi_ad_monitorConnectionWrite;
119 AttributeDescription *mi_ad_monitorConnectionMask;
120 AttributeDescription *mi_ad_monitorConnectionListener;
121 AttributeDescription *mi_ad_monitorConnectionPeerDomain;
122 AttributeDescription *mi_ad_monitorConnectionStartTime;
123 AttributeDescription *mi_ad_monitorConnectionActivityTime;
124 AttributeDescription *mi_ad_monitorIsShadow;
125 AttributeDescription *mi_ad_monitorUpdateRef;
126 AttributeDescription *mi_ad_monitorRuntimeConfig;
129 * Generic description attribute
131 AttributeDescription *mi_ad_readOnly;
132 AttributeDescription *mi_ad_restrictedOperation;
134 void *mi_entry_limbo;
142 SLAPD_MONITOR_BACKEND = 0,
144 SLAPD_MONITOR_DATABASE,
145 SLAPD_MONITOR_LISTENER,
148 SLAPD_MONITOR_OVERLAY,
151 SLAPD_MONITOR_THREAD,
159 #define SLAPD_MONITOR_AT "cn"
161 #define SLAPD_MONITOR_BACKEND_NAME "Backends"
162 #define SLAPD_MONITOR_BACKEND_RDN \
163 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
164 #define SLAPD_MONITOR_BACKEND_DN \
165 SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
167 #define SLAPD_MONITOR_CONN_NAME "Connections"
168 #define SLAPD_MONITOR_CONN_RDN \
169 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
170 #define SLAPD_MONITOR_CONN_DN \
171 SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
173 #define SLAPD_MONITOR_DATABASE_NAME "Databases"
174 #define SLAPD_MONITOR_DATABASE_RDN \
175 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
176 #define SLAPD_MONITOR_DATABASE_DN \
177 SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
179 #define SLAPD_MONITOR_LISTENER_NAME "Listeners"
180 #define SLAPD_MONITOR_LISTENER_RDN \
181 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
182 #define SLAPD_MONITOR_LISTENER_DN \
183 SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
185 #define SLAPD_MONITOR_LOG_NAME "Log"
186 #define SLAPD_MONITOR_LOG_RDN \
187 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
188 #define SLAPD_MONITOR_LOG_DN \
189 SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
191 #define SLAPD_MONITOR_OPS_NAME "Operations"
192 #define SLAPD_MONITOR_OPS_RDN \
193 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
194 #define SLAPD_MONITOR_OPS_DN \
195 SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
197 #define SLAPD_MONITOR_OVERLAY_NAME "Overlays"
198 #define SLAPD_MONITOR_OVERLAY_RDN \
199 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
200 #define SLAPD_MONITOR_OVERLAY_DN \
201 SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
203 #define SLAPD_MONITOR_SASL_NAME "SASL"
204 #define SLAPD_MONITOR_SASL_RDN \
205 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
206 #define SLAPD_MONITOR_SASL_DN \
207 SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
209 #define SLAPD_MONITOR_SENT_NAME "Statistics"
210 #define SLAPD_MONITOR_SENT_RDN \
211 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
212 #define SLAPD_MONITOR_SENT_DN \
213 SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
215 #define SLAPD_MONITOR_THREAD_NAME "Threads"
216 #define SLAPD_MONITOR_THREAD_RDN \
217 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
218 #define SLAPD_MONITOR_THREAD_DN \
219 SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
221 #define SLAPD_MONITOR_TIME_NAME "Time"
222 #define SLAPD_MONITOR_TIME_RDN \
223 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
224 #define SLAPD_MONITOR_TIME_DN \
225 SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
227 #define SLAPD_MONITOR_TLS_NAME "TLS"
228 #define SLAPD_MONITOR_TLS_RDN \
229 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
230 #define SLAPD_MONITOR_TLS_DN \
231 SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
233 #define SLAPD_MONITOR_RWW_NAME "Waiters"
234 #define SLAPD_MONITOR_RWW_RDN \
235 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
236 #define SLAPD_MONITOR_RWW_DN \
237 SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
239 typedef struct monitor_subsys_t {
241 struct berval mss_rdn;
242 struct berval mss_dn;
243 struct berval mss_ndn;
244 struct berval mss_desc[ 3 ];
246 #define MONITOR_F_OPENED 0x10000000U
248 #define MONITOR_HAS_VOLATILE_CH( mp ) \
249 ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
250 #define MONITOR_HAS_CHILDREN( mp ) \
251 ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
253 /* initialize entry and subentries */
254 int ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms );
255 /* destroy structure */
256 int ( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms );
257 /* update existing dynamic entry and subentries */
258 int ( *mss_update )( Operation *, SlapReply *, Entry * );
259 /* create new dynamic subentries */
260 int ( *mss_create )( Operation *, SlapReply *,
261 struct berval *ndn, Entry *, Entry ** );
262 /* modify entry and subentries */
263 int ( *mss_modify )( Operation *, SlapReply *, Entry * );
266 extern BackendDB *be_monitor;
268 /* increase this bufsize if entries in string form get too big */
269 #define BACKMONITOR_BUFSIZE 8192
271 typedef int (monitor_cbfunc)( struct berval *ndn, monitor_callback_t *cb,
272 struct berval *base, int scope, struct berval *filter );
274 typedef int (monitor_cbafunc)( struct berval *ndn, Attribute *a,
275 monitor_callback_t *cb,
276 struct berval *base, int scope, struct berval *filter );
278 typedef struct monitor_extra_t {
279 int (*is_configured)(void);
280 monitor_subsys_t * (*get_subsys)( const char *name );
281 monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub );
283 int (*register_subsys)( monitor_subsys_t *ms );
284 int (*register_entry)( Entry *e, monitor_callback_t *cb,
285 monitor_subsys_t *ms, unsigned long flags );
286 int (*register_entry_parent)( Entry *e, monitor_callback_t *cb,
287 monitor_subsys_t *ms, unsigned long flags,
288 struct berval *base, int scope, struct berval *filter );
289 monitor_cbafunc *register_entry_attrs;
290 monitor_cbfunc *register_entry_callback;
292 int (*unregister_entry)( struct berval *ndn );
293 monitor_cbfunc *unregister_entry_parent;
294 monitor_cbafunc *unregister_entry_attrs;
295 monitor_cbfunc *unregister_entry_callback;
300 #include "proto-back-monitor.h"
302 #endif /* _back_monitor_h_ */