bi->bi_connection_init = 0;
bi->bi_connection_destroy = 0;
- /*
- * initialize monitor stuff
- */
- rc = bdb_monitor_initialize();
- if ( rc ) {
- return rc;
- }
-
rc = bdb_back_init_cf( bi );
return rc;
#include "lutil.h"
#include "back-bdb.h"
-#ifdef SLAPD_MONITOR
-
#include "../back-monitor/back-monitor.h"
static ObjectClass *oc_olmBDBDatabase;
return SLAP_CB_CONTINUE;
}
-#endif /* SLAPD_MONITOR */
-
/*
* call from within bdb_initialize()
*/
int
bdb_monitor_initialize( void )
{
-#ifdef SLAPD_MONITOR
int i, code;
const char *err;
+ BackendInfo *bi;
static int bdb_monitor_initialized = 0;
- /* register schema here; if compiled as dynamic object,
- * must be loaded __after__ back_monitor.la */
+ bi = backend_info("monitor");
+ if ( !bi )
+ return -1;
+
+ /* register schema here */
if ( bdb_monitor_initialized++ ) {
return 0;
ldap_memfree( oc );
}
-#endif /* SLAPD_MONITOR */
return 0;
}
int
bdb_monitor_init( BackendDB *be )
{
-#ifdef SLAPD_MONITOR
- SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_MONITORING;
-#endif /* SLAPD_MONITOR */
+ if ( bdb_monitor_initialize() == LDAP_SUCCESS ) {
+ SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_MONITORING;
+ }
return 0;
}
int
bdb_monitor_open( BackendDB *be )
{
-#ifdef SLAPD_MONITOR
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
Attribute *a, *next;
monitor_callback_t *cb = NULL;
struct berval suffix, *filter, *base;
char *ptr;
int rc = 0;
+ monitor_extra_t *mbe;
if ( !SLAP_DBMONITORING( be ) ) {
return 0;
}
+ {
+ BackendInfo *mi = backend_info( "monitor" );
+ if ( !mi || !mi->bi_extra ) {
+ SLAP_DBFLAGS( be ) ^= SLAP_DBFLAG_MONITORING;
+ return 0;
+ }
+ mbe = mi->bi_extra;
+ }
+
/* don't bother if monitor is not configured */
- if ( !monitor_back_is_configured() ) {
+ if ( !mbe->is_configured() ) {
static int warning = 0;
if ( warning++ == 0 ) {
cb->mc_free = bdb_monitor_free;
cb->mc_private = (void *)bdb;
- rc = monitor_back_register_entry_attrs( NULL, a, cb,
+ rc = mbe->register_entry_attrs( NULL, a, cb,
base, LDAP_SCOPE_SUBORDINATE, filter );
cleanup:;
}
return rc;
-#else /* !SLAPD_MONITOR */
- return 0;
-#endif /* SLAPD_MONITOR */
}
/*
int
bdb_monitor_close( BackendDB *be )
{
-#ifdef SLAPD_MONITOR
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
if ( !BER_BVISNULL( &bdb->bi_monitor.bdm_filter ) ) {
- monitor_back_unregister_entry_callback( NULL,
+ BackendInfo *mi = backend_info( "monitor" );
+ monitor_extra_t *mbe;
+
+ if ( !mi || !mi->bi_extra )
+ return 0;
+ mbe = mi->bi_extra;
+ mbe->unregister_entry_callback( NULL,
(monitor_callback_t *)bdb->bi_monitor.bdm_cb,
&bdb->bi_monitor.bdm_nbase,
bdb->bi_monitor.bdm_scope,
memset( &bdb->bi_monitor, 0, sizeof( bdb->bi_monitor ) );
}
-#endif /* SLAPD_MONITOR */
return 0;
}
/* increase this bufsize if entries in string form get too big */
#define BACKMONITOR_BUFSIZE 8192
+typedef int (monitor_cbfunc)( struct berval *ndn, monitor_callback_t *cb,
+ struct berval *base, int scope, struct berval *filter );
+
+typedef int (monitor_cbafunc)( struct berval *ndn, Attribute *a,
+ monitor_callback_t *cb,
+ struct berval *base, int scope, struct berval *filter );
+
+typedef struct monitor_extra_t {
+ int (*is_configured)(void);
+ monitor_subsys_t * (*get_subsys)( const char *name );
+ monitor_subsys_t * (*get_subsys_by_dn)( struct berval *ndn, int sub );
+
+ int (*register_subsys)( monitor_subsys_t *ms );
+ int (*register_entry)( Entry *e, monitor_callback_t *cb,
+ monitor_subsys_t *ms, unsigned long flags );
+ int (*register_entry_parent)( Entry *e, monitor_callback_t *cb,
+ monitor_subsys_t *ms, unsigned long flags,
+ struct berval *base, int scope, struct berval *filter );
+ monitor_cbafunc *register_entry_attrs;
+ monitor_cbfunc *register_entry_callback;
+
+ int (*unregister_entry)( struct berval *ndn );
+ monitor_cbfunc *unregister_entry_parent;
+ monitor_cbafunc *unregister_entry_attrs;
+ monitor_cbfunc *unregister_entry_callback;
+} monitor_extra_t;
+
LDAP_END_DECL
#include "proto-back-monitor.h"
static struct monitor_subsys_t **monitor_subsys;
static int monitor_subsys_opened;
static monitor_info_t monitor_info;
+static const monitor_extra_t monitor_extra = {
+ monitor_back_is_configured,
+ monitor_back_get_subsys,
+ monitor_back_get_subsys_by_dn,
+
+ monitor_back_register_subsys,
+ monitor_back_register_entry,
+ monitor_back_register_entry_parent,
+ monitor_back_register_entry_attrs,
+ monitor_back_register_entry_callback,
+
+ monitor_back_unregister_entry,
+ monitor_back_unregister_entry_parent,
+ monitor_back_unregister_entry_attrs,
+ monitor_back_unregister_entry_callback
+};
+
/*
* subsystem data
bi->bi_connection_init = 0;
bi->bi_connection_destroy = 0;
+ bi->bi_extra = (void *)&monitor_extra;
+
/*
* configuration objectClasses (fake)
*/
unsigned int bi_nDB; /* number of databases of this type */
struct ConfigOCs *bi_cf_ocs;
char **bi_obsolete_names;
- void *bi_private; /* anything the backend type needs */
+ void *bi_extra; /* backend type-specific APIs */
+ void *bi_private; /* backend type-specific config data */
LDAP_STAILQ_ENTRY(slap_backend_info) bi_next ;
};