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-2011 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_dispose)( void **priv );
47 to dispose of the callback
48 private data itself */
49 void *mc_private; /* opaque pointer to
51 struct monitor_callback_t *mc_next;
55 typedef struct monitor_entry_t {
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 monitor_subsys_t *mp_info; /* subsystem info */
60 #define mp_type mp_info->mss_type
61 unsigned long mp_flags; /* flags */
63 #define MONITOR_F_NONE 0x0000U
64 #define MONITOR_F_SUB 0x0001U /* subentry of subsystem */
65 #define MONITOR_F_PERSISTENT 0x0010U /* persistent entry */
66 #define MONITOR_F_PERSISTENT_CH 0x0020U /* subsystem generates
68 #define MONITOR_F_VOLATILE 0x0040U /* volatile entry */
69 #define MONITOR_F_VOLATILE_CH 0x0080U /* subsystem generates
71 #define MONITOR_F_EXTERNAL 0x0100U /* externally added - don't free */
72 /* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */
74 struct monitor_callback_t *mp_cb; /* callback sequence */
77 struct entry_limbo_t; /* in init.c */
79 typedef struct monitor_info_t {
85 ldap_pvt_thread_mutex_t mi_cache_mutex;
90 struct berval mi_startTime; /* don't free it! */
91 struct berval mi_creatorsName; /* don't free it! */
92 struct berval mi_ncreatorsName; /* don't free it! */
95 * Specific schema entities
97 ObjectClass *mi_oc_monitor;
98 ObjectClass *mi_oc_monitorServer;
99 ObjectClass *mi_oc_monitorContainer;
100 ObjectClass *mi_oc_monitorCounterObject;
101 ObjectClass *mi_oc_monitorOperation;
102 ObjectClass *mi_oc_monitorConnection;
103 ObjectClass *mi_oc_managedObject;
104 ObjectClass *mi_oc_monitoredObject;
106 AttributeDescription *mi_ad_monitoredInfo;
107 AttributeDescription *mi_ad_managedInfo;
108 AttributeDescription *mi_ad_monitorCounter;
109 AttributeDescription *mi_ad_monitorOpCompleted;
110 AttributeDescription *mi_ad_monitorOpInitiated;
111 AttributeDescription *mi_ad_monitorConnectionNumber;
112 AttributeDescription *mi_ad_monitorConnectionAuthzDN;
113 AttributeDescription *mi_ad_monitorConnectionLocalAddress;
114 AttributeDescription *mi_ad_monitorConnectionPeerAddress;
115 AttributeDescription *mi_ad_monitorTimestamp;
116 AttributeDescription *mi_ad_monitorOverlay;
117 AttributeDescription *mi_ad_monitorConnectionProtocol;
118 AttributeDescription *mi_ad_monitorConnectionOpsReceived;
119 AttributeDescription *mi_ad_monitorConnectionOpsExecuting;
120 AttributeDescription *mi_ad_monitorConnectionOpsPending;
121 AttributeDescription *mi_ad_monitorConnectionOpsCompleted;
122 AttributeDescription *mi_ad_monitorConnectionGet;
123 AttributeDescription *mi_ad_monitorConnectionRead;
124 AttributeDescription *mi_ad_monitorConnectionWrite;
125 AttributeDescription *mi_ad_monitorConnectionMask;
126 AttributeDescription *mi_ad_monitorConnectionListener;
127 AttributeDescription *mi_ad_monitorConnectionPeerDomain;
128 AttributeDescription *mi_ad_monitorConnectionStartTime;
129 AttributeDescription *mi_ad_monitorConnectionActivityTime;
130 AttributeDescription *mi_ad_monitorIsShadow;
131 AttributeDescription *mi_ad_monitorUpdateRef;
132 AttributeDescription *mi_ad_monitorRuntimeConfig;
133 AttributeDescription *mi_ad_monitorSuperiorDN;
136 * Generic description attribute
138 AttributeDescription *mi_ad_readOnly;
139 AttributeDescription *mi_ad_restrictedOperation;
141 struct entry_limbo_t *mi_entry_limbo;
149 SLAPD_MONITOR_BACKEND = 0,
151 SLAPD_MONITOR_DATABASE,
152 SLAPD_MONITOR_LISTENER,
155 SLAPD_MONITOR_OVERLAY,
158 SLAPD_MONITOR_THREAD,
166 #define SLAPD_MONITOR_AT "cn"
168 #define SLAPD_MONITOR_BACKEND_NAME "Backends"
169 #define SLAPD_MONITOR_BACKEND_RDN \
170 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
171 #define SLAPD_MONITOR_BACKEND_DN \
172 SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
174 #define SLAPD_MONITOR_CONN_NAME "Connections"
175 #define SLAPD_MONITOR_CONN_RDN \
176 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
177 #define SLAPD_MONITOR_CONN_DN \
178 SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
180 #define SLAPD_MONITOR_DATABASE_NAME "Databases"
181 #define SLAPD_MONITOR_DATABASE_RDN \
182 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
183 #define SLAPD_MONITOR_DATABASE_DN \
184 SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
186 #define SLAPD_MONITOR_LISTENER_NAME "Listeners"
187 #define SLAPD_MONITOR_LISTENER_RDN \
188 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
189 #define SLAPD_MONITOR_LISTENER_DN \
190 SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
192 #define SLAPD_MONITOR_LOG_NAME "Log"
193 #define SLAPD_MONITOR_LOG_RDN \
194 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
195 #define SLAPD_MONITOR_LOG_DN \
196 SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
198 #define SLAPD_MONITOR_OPS_NAME "Operations"
199 #define SLAPD_MONITOR_OPS_RDN \
200 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
201 #define SLAPD_MONITOR_OPS_DN \
202 SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
204 #define SLAPD_MONITOR_OVERLAY_NAME "Overlays"
205 #define SLAPD_MONITOR_OVERLAY_RDN \
206 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
207 #define SLAPD_MONITOR_OVERLAY_DN \
208 SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
210 #define SLAPD_MONITOR_SASL_NAME "SASL"
211 #define SLAPD_MONITOR_SASL_RDN \
212 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
213 #define SLAPD_MONITOR_SASL_DN \
214 SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
216 #define SLAPD_MONITOR_SENT_NAME "Statistics"
217 #define SLAPD_MONITOR_SENT_RDN \
218 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
219 #define SLAPD_MONITOR_SENT_DN \
220 SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
222 #define SLAPD_MONITOR_THREAD_NAME "Threads"
223 #define SLAPD_MONITOR_THREAD_RDN \
224 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
225 #define SLAPD_MONITOR_THREAD_DN \
226 SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
228 #define SLAPD_MONITOR_TIME_NAME "Time"
229 #define SLAPD_MONITOR_TIME_RDN \
230 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
231 #define SLAPD_MONITOR_TIME_DN \
232 SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
234 #define SLAPD_MONITOR_TLS_NAME "TLS"
235 #define SLAPD_MONITOR_TLS_RDN \
236 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
237 #define SLAPD_MONITOR_TLS_DN \
238 SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
240 #define SLAPD_MONITOR_RWW_NAME "Waiters"
241 #define SLAPD_MONITOR_RWW_RDN \
242 SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
243 #define SLAPD_MONITOR_RWW_DN \
244 SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
246 typedef struct monitor_subsys_t {
248 struct berval mss_rdn;
249 struct berval mss_dn;
250 struct berval mss_ndn;
251 struct berval mss_desc[ 3 ];
253 #define MONITOR_F_OPENED 0x10000000U
255 #define MONITOR_HAS_VOLATILE_CH( mp ) \
256 ( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH )
257 #define MONITOR_HAS_CHILDREN( mp ) \
258 ( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) )
260 /* initialize entry and subentries */
261 int ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms );
262 /* destroy structure */
263 int ( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms );
264 /* update existing dynamic entry and subentries */
265 int ( *mss_update )( Operation *, SlapReply *, Entry * );
266 /* create new dynamic subentries */
267 int ( *mss_create )( Operation *, SlapReply *,
268 struct berval *ndn, Entry *, Entry ** );
269 /* modify entry and subentries */
270 int ( *mss_modify )( Operation *, SlapReply *, Entry * );
273 extern BackendDB *be_monitor;
275 /* increase this bufsize if entries in string form get too big */
276 #define BACKMONITOR_BUFSIZE 8192
278 typedef int (monitor_cbfunc)( struct berval *ndn, monitor_callback_t *cb,
279 struct berval *base, int scope, struct berval *filter );
281 typedef int (monitor_cbafunc)( struct berval *ndn, Attribute *a,
282 monitor_callback_t *cb,
283 struct berval *base, int scope, struct berval *filter );
285 typedef struct monitor_extra_t {
286 int (*is_configured)(void);
287 monitor_subsys_t * (*get_subsys)( const char *name );
288 monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub );
290 int (*register_subsys)( monitor_subsys_t *ms );
291 int (*register_backend)( BackendInfo *bi );
292 int (*register_database)( BackendDB *be, struct berval *ndn_out );
293 int (*register_overlay_info)( slap_overinst *on );
294 int (*register_overlay)( BackendDB *be, slap_overinst *on, struct berval *ndn_out );
295 int (*register_entry)( Entry *e, monitor_callback_t *cb,
296 monitor_subsys_t *ms, unsigned long flags );
297 int (*register_entry_parent)( Entry *e, monitor_callback_t *cb,
298 monitor_subsys_t *ms, unsigned long flags,
299 struct berval *base, int scope, struct berval *filter );
300 monitor_cbafunc *register_entry_attrs;
301 monitor_cbfunc *register_entry_callback;
303 int (*unregister_entry)( struct berval *ndn );
304 monitor_cbfunc *unregister_entry_parent;
305 monitor_cbafunc *unregister_entry_attrs;
306 monitor_cbfunc *unregister_entry_callback;
311 #include "proto-back-monitor.h"
313 #endif /* _back_monitor_h_ */