| 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-2024 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 <ldap_avl.h> |
| 28 |
#include <slap.h> |
| 29 |
|
| 30 |
LDAP_BEGIN_DECL |
| 31 |
|
| 32 |
/* define if si_ad_labeledURI is removed from slap_schema */ |
| 33 |
#undef MONITOR_DEFINE_LABELEDURI |
| 34 |
|
| 35 |
typedef struct monitor_callback_t { |
| 36 |
int (*mc_update)( Operation *op, SlapReply *rs, Entry *e, void *priv ); |
| 37 |
/* update callback |
| 38 |
for user-defined entries */ |
| 39 |
int (*mc_modify)( Operation *op, SlapReply *rs, Entry *e, void *priv ); |
| 40 |
/* modify callback |
| 41 |
for user-defined entries */ |
| 42 |
int (*mc_free)( Entry *e, void **priv ); |
| 43 |
/* delete callback |
| 44 |
for user-defined entries */ |
| 45 |
void (*mc_dispose)( void **priv ); |
| 46 |
/* dispose callback |
| 47 |
to dispose of the callback |
| 48 |
private data itself */ |
| 49 |
void *mc_private; /* opaque pointer to |
| 50 |
private data */ |
| 51 |
struct monitor_callback_t *mc_next; |
| 52 |
} monitor_callback_t; |
| 53 |
|
| 54 |
|
| 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 |
Entry *mp_last; /* pointer to last child */ |
| 60 |
struct monitor_subsys_t *mp_info; /* subsystem info */ |
| 61 |
#define mp_type mp_info->mss_type |
| 62 |
unsigned long mp_flags; /* flags */ |
| 63 |
|
| 64 |
#define MONITOR_F_NONE 0x0000U |
| 65 |
#define MONITOR_F_SUB 0x0001U /* subentry of subsystem */ |
| 66 |
#define MONITOR_F_PERSISTENT 0x0010U /* persistent entry */ |
| 67 |
#define MONITOR_F_PERSISTENT_CH 0x0020U /* subsystem generates |
| 68 |
persistent entries */ |
| 69 |
#define MONITOR_F_VOLATILE 0x0040U /* volatile entry */ |
| 70 |
#define MONITOR_F_VOLATILE_CH 0x0080U /* subsystem generates |
| 71 |
volatile entries */ |
| 72 |
#define MONITOR_F_EXTERNAL 0x0100U /* externally added - don't free */ |
| 73 |
/* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */ |
| 74 |
|
| 75 |
struct monitor_callback_t *mp_cb; /* callback sequence */ |
| 76 |
void *mp_private; |
| 77 |
} monitor_entry_t; |
| 78 |
|
| 79 |
struct entry_limbo_t; /* in init.c */ |
| 80 |
|
| 81 |
typedef struct monitor_info_t { |
| 82 |
|
| 83 |
/* |
| 84 |
* Internal data |
| 85 |
* |
| 86 |
* Lock order: |
| 87 |
* - cache first, then entry |
| 88 |
* - DIT in preorder DFS |
| 89 |
*/ |
| 90 |
Avlnode *mi_cache; |
| 91 |
ldap_pvt_thread_mutex_t mi_cache_lock; |
| 92 |
|
| 93 |
/* |
| 94 |
* Config parameters |
| 95 |
*/ |
| 96 |
struct berval mi_startTime; /* don't free it! */ |
| 97 |
struct berval mi_creatorsName; /* don't free it! */ |
| 98 |
struct berval mi_ncreatorsName; /* don't free it! */ |
| 99 |
|
| 100 |
/* |
| 101 |
* Specific schema entities |
| 102 |
*/ |
| 103 |
ObjectClass *mi_oc_monitor; |
| 104 |
ObjectClass *mi_oc_monitorServer; |
| 105 |
ObjectClass *mi_oc_monitorContainer; |
| 106 |
ObjectClass *mi_oc_monitorCounterObject; |
| 107 |
ObjectClass *mi_oc_monitorOperation; |
| 108 |
ObjectClass *mi_oc_monitorConnection; |
| 109 |
ObjectClass *mi_oc_managedObject; |
| 110 |
ObjectClass *mi_oc_monitoredObject; |
| 111 |
|
| 112 |
AttributeDescription *mi_ad_monitoredInfo; |
| 113 |
AttributeDescription *mi_ad_managedInfo; |
| 114 |
AttributeDescription *mi_ad_monitorCounter; |
| 115 |
AttributeDescription *mi_ad_monitorOpCompleted; |
| 116 |
AttributeDescription *mi_ad_monitorOpInitiated; |
| 117 |
AttributeDescription *mi_ad_monitorConnectionNumber; |
| 118 |
AttributeDescription *mi_ad_monitorConnectionAuthzDN; |
| 119 |
AttributeDescription *mi_ad_monitorConnectionLocalAddress; |
| 120 |
AttributeDescription *mi_ad_monitorConnectionPeerAddress; |
| 121 |
AttributeDescription *mi_ad_monitorTimestamp; |
| 122 |
AttributeDescription *mi_ad_monitorOverlay; |
| 123 |
AttributeDescription *mi_ad_monitorConnectionProtocol; |
| 124 |
AttributeDescription *mi_ad_monitorConnectionOpsReceived; |
| 125 |
AttributeDescription *mi_ad_monitorConnectionOpsExecuting; |
| 126 |
AttributeDescription *mi_ad_monitorConnectionOpsPending; |
| 127 |
AttributeDescription *mi_ad_monitorConnectionOpsCompleted; |
| 128 |
AttributeDescription *mi_ad_monitorConnectionGet; |
| 129 |
AttributeDescription *mi_ad_monitorConnectionRead; |
| 130 |
AttributeDescription *mi_ad_monitorConnectionWrite; |
| 131 |
AttributeDescription *mi_ad_monitorConnectionMask; |
| 132 |
AttributeDescription *mi_ad_monitorConnectionListener; |
| 133 |
AttributeDescription *mi_ad_monitorConnectionPeerDomain; |
| 134 |
AttributeDescription *mi_ad_monitorConnectionStartTime; |
| 135 |
AttributeDescription *mi_ad_monitorConnectionActivityTime; |
| 136 |
AttributeDescription *mi_ad_monitorIsShadow; |
| 137 |
AttributeDescription *mi_ad_monitorUpdateRef; |
| 138 |
AttributeDescription *mi_ad_monitorRuntimeConfig; |
| 139 |
AttributeDescription *mi_ad_monitorSuperiorDN; |
| 140 |
AttributeDescription *mi_ad_monitorConnectionOpsAsync; |
| 141 |
AttributeDescription *mi_ad_monitorLogLevel; |
| 142 |
AttributeDescription *mi_ad_monitorDebugLevel; |
| 143 |
|
| 144 |
/* |
| 145 |
* Generic description attribute |
| 146 |
*/ |
| 147 |
AttributeDescription *mi_ad_readOnly; |
| 148 |
AttributeDescription *mi_ad_restrictedOperation; |
| 149 |
|
| 150 |
struct entry_limbo_t *mi_entry_limbo; |
| 151 |
} monitor_info_t; |
| 152 |
|
| 153 |
/* |
| 154 |
* DNs |
| 155 |
*/ |
| 156 |
|
| 157 |
enum { |
| 158 |
SLAPD_MONITOR_BACKEND = 0, |
| 159 |
SLAPD_MONITOR_CONN, |
| 160 |
SLAPD_MONITOR_DATABASE, |
| 161 |
SLAPD_MONITOR_LISTENER, |
| 162 |
SLAPD_MONITOR_LOG, |
| 163 |
SLAPD_MONITOR_OPS, |
| 164 |
SLAPD_MONITOR_OVERLAY, |
| 165 |
SLAPD_MONITOR_SASL, |
| 166 |
SLAPD_MONITOR_SENT, |
| 167 |
SLAPD_MONITOR_THREAD, |
| 168 |
SLAPD_MONITOR_TIME, |
| 169 |
SLAPD_MONITOR_TLS, |
| 170 |
SLAPD_MONITOR_RWW, |
| 171 |
|
| 172 |
SLAPD_MONITOR_LAST |
| 173 |
}; |
| 174 |
|
| 175 |
#define SLAPD_MONITOR_AT "cn" |
| 176 |
|
| 177 |
#define SLAPD_MONITOR_BACKEND_NAME "Backends" |
| 178 |
#define SLAPD_MONITOR_BACKEND_RDN \ |
| 179 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME |
| 180 |
#define SLAPD_MONITOR_BACKEND_DN \ |
| 181 |
SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN |
| 182 |
|
| 183 |
#define SLAPD_MONITOR_CONN_NAME "Connections" |
| 184 |
#define SLAPD_MONITOR_CONN_RDN \ |
| 185 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME |
| 186 |
#define SLAPD_MONITOR_CONN_DN \ |
| 187 |
SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN |
| 188 |
|
| 189 |
#define SLAPD_MONITOR_DATABASE_NAME "Databases" |
| 190 |
#define SLAPD_MONITOR_DATABASE_RDN \ |
| 191 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME |
| 192 |
#define SLAPD_MONITOR_DATABASE_DN \ |
| 193 |
SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN |
| 194 |
|
| 195 |
#define SLAPD_MONITOR_LISTENER_NAME "Listeners" |
| 196 |
#define SLAPD_MONITOR_LISTENER_RDN \ |
| 197 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME |
| 198 |
#define SLAPD_MONITOR_LISTENER_DN \ |
| 199 |
SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN |
| 200 |
|
| 201 |
#define SLAPD_MONITOR_LOG_NAME "Log" |
| 202 |
#define SLAPD_MONITOR_LOG_RDN \ |
| 203 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME |
| 204 |
#define SLAPD_MONITOR_LOG_DN \ |
| 205 |
SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN |
| 206 |
|
| 207 |
#define SLAPD_MONITOR_OPS_NAME "Operations" |
| 208 |
#define SLAPD_MONITOR_OPS_RDN \ |
| 209 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME |
| 210 |
#define SLAPD_MONITOR_OPS_DN \ |
| 211 |
SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN |
| 212 |
|
| 213 |
#define SLAPD_MONITOR_OVERLAY_NAME "Overlays" |
| 214 |
#define SLAPD_MONITOR_OVERLAY_RDN \ |
| 215 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME |
| 216 |
#define SLAPD_MONITOR_OVERLAY_DN \ |
| 217 |
SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN |
| 218 |
|
| 219 |
#define SLAPD_MONITOR_SASL_NAME "SASL" |
| 220 |
#define SLAPD_MONITOR_SASL_RDN \ |
| 221 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME |
| 222 |
#define SLAPD_MONITOR_SASL_DN \ |
| 223 |
SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN |
| 224 |
|
| 225 |
#define SLAPD_MONITOR_SENT_NAME "Statistics" |
| 226 |
#define SLAPD_MONITOR_SENT_RDN \ |
| 227 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME |
| 228 |
#define SLAPD_MONITOR_SENT_DN \ |
| 229 |
SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN |
| 230 |
|
| 231 |
#define SLAPD_MONITOR_THREAD_NAME "Threads" |
| 232 |
#define SLAPD_MONITOR_THREAD_RDN \ |
| 233 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME |
| 234 |
#define SLAPD_MONITOR_THREAD_DN \ |
| 235 |
SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN |
| 236 |
|
| 237 |
#define SLAPD_MONITOR_TIME_NAME "Time" |
| 238 |
#define SLAPD_MONITOR_TIME_RDN \ |
| 239 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME |
| 240 |
#define SLAPD_MONITOR_TIME_DN \ |
| 241 |
SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN |
| 242 |
|
| 243 |
#define SLAPD_MONITOR_TLS_NAME "TLS" |
| 244 |
#define SLAPD_MONITOR_TLS_RDN \ |
| 245 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME |
| 246 |
#define SLAPD_MONITOR_TLS_DN \ |
| 247 |
SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN |
| 248 |
|
| 249 |
#define SLAPD_MONITOR_RWW_NAME "Waiters" |
| 250 |
#define SLAPD_MONITOR_RWW_RDN \ |
| 251 |
SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME |
| 252 |
#define SLAPD_MONITOR_RWW_DN \ |
| 253 |
SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN |
| 254 |
|
| 255 |
typedef struct monitor_subsys_t { |
| 256 |
char *mss_name; |
| 257 |
struct berval mss_rdn; |
| 258 |
struct berval mss_dn; |
| 259 |
struct berval mss_ndn; |
| 260 |
struct berval mss_desc[ 3 ]; |
| 261 |
int mss_flags; |
| 262 |
#define MONITOR_F_OPENED 0x10000000U |
| 263 |
|
| 264 |
#define MONITOR_HAS_VOLATILE_CH( mp ) \ |
| 265 |
( ( mp )->mp_flags & MONITOR_F_VOLATILE_CH ) |
| 266 |
#define MONITOR_HAS_CHILDREN( mp ) \ |
| 267 |
( ( mp )->mp_children || MONITOR_HAS_VOLATILE_CH( mp ) ) |
| 268 |
|
| 269 |
/* initialize entry and subentries */ |
| 270 |
int ( *mss_open )( BackendDB *, struct monitor_subsys_t *ms ); |
| 271 |
/* destroy structure */ |
| 272 |
int ( *mss_destroy )( BackendDB *, struct monitor_subsys_t *ms ); |
| 273 |
/* update existing dynamic entry and subentries */ |
| 274 |
int ( *mss_update )( Operation *, SlapReply *, Entry * ); |
| 275 |
/* create new dynamic subentries */ |
| 276 |
int ( *mss_create )( Operation *, SlapReply *, |
| 277 |
struct berval *ndn, Entry *, Entry ** ); |
| 278 |
/* modify entry and subentries */ |
| 279 |
int ( *mss_modify )( Operation *, SlapReply *, Entry * ); |
| 280 |
|
| 281 |
void *mss_private; |
| 282 |
} monitor_subsys_t; |
| 283 |
|
| 284 |
extern BackendDB *be_monitor; |
| 285 |
|
| 286 |
/* increase this bufsize if entries in string form get too big */ |
| 287 |
#define BACKMONITOR_BUFSIZE 8192 |
| 288 |
|
| 289 |
typedef int (monitor_cbfunc)( struct berval *ndn, monitor_callback_t *cb, |
| 290 |
struct berval *base, int scope, struct berval *filter ); |
| 291 |
|
| 292 |
typedef int (monitor_cbafunc)( struct berval *ndn, Attribute *a, |
| 293 |
monitor_callback_t *cb, |
| 294 |
struct berval *base, int scope, struct berval *filter ); |
| 295 |
|
| 296 |
typedef struct monitor_extra_t { |
| 297 |
int (*is_configured)(void); |
| 298 |
monitor_subsys_t * (*get_subsys)( const char *name ); |
| 299 |
monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub ); |
| 300 |
|
| 301 |
int (*register_subsys)( monitor_subsys_t *ms ); |
| 302 |
int (*register_backend)( BackendInfo *bi ); |
| 303 |
int (*register_database)( BackendDB *be, struct berval *ndn_out ); |
| 304 |
int (*register_overlay_info)( slap_overinst *on ); |
| 305 |
int (*register_overlay)( BackendDB *be, slap_overinst *on, struct berval *ndn_out ); |
| 306 |
int (*register_entry)( Entry *e, monitor_callback_t *cb, |
| 307 |
monitor_subsys_t *ms, unsigned long flags ); |
| 308 |
int (*register_entry_parent)( Entry *e, monitor_callback_t *cb, |
| 309 |
monitor_subsys_t *ms, unsigned long flags, |
| 310 |
struct berval *base, int scope, struct berval *filter ); |
| 311 |
monitor_cbafunc *register_entry_attrs; |
| 312 |
monitor_cbfunc *register_entry_callback; |
| 313 |
|
| 314 |
int (*unregister_entry)( struct berval *ndn ); |
| 315 |
monitor_cbfunc *unregister_entry_parent; |
| 316 |
monitor_cbafunc *unregister_entry_attrs; |
| 317 |
monitor_cbfunc *unregister_entry_callback; |
| 318 |
Entry * (*entry_stub)( struct berval *pdn, |
| 319 |
struct berval *pndn, |
| 320 |
struct berval *rdn, |
| 321 |
ObjectClass *oc, |
| 322 |
struct berval *create, |
| 323 |
struct berval *modify ); |
| 324 |
monitor_entry_t * (*entrypriv_create)( void ); |
| 325 |
int (*register_subsys_late)( monitor_subsys_t *ms ); |
| 326 |
Entry * (*entry_get_unlocked)( struct berval *ndn ); |
| 327 |
} monitor_extra_t; |
| 328 |
|
| 329 |
LDAP_END_DECL |
| 330 |
|
| 331 |
#include "proto-back-monitor.h" |
| 332 |
|
| 333 |
#endif /* _back_monitor_h_ */ |
| 334 |
|