1 /* listener.c - deals with listener subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2004 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.
27 #include "back-monitor.h"
30 monitor_subsys_listener_init(
34 struct monitorinfo *mi;
35 Entry *e, *e_listener, *e_tmp;
37 struct monitorentrypriv *mp;
42 mi = ( struct monitorinfo * )be->be_private;
44 if ( monitor_cache_get( mi,
45 &monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn,
48 LDAP_LOG( OPERATION, CRIT,
49 "monitor_subsys_listener_init: "
50 "unable to get entry '%s'\n",
51 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0, 0 );
53 Debug( LDAP_DEBUG_ANY,
54 "monitor_subsys_listener_init: "
55 "unable to get entry '%s'\n%s%s",
56 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
62 if ( ( l = slapd_get_listeners() ) == NULL ) {
64 LDAP_LOG( OPERATION, CRIT,
65 "monitor_subsys_listener_init: "
66 "unable to get listeners\n", 0, 0, 0 );
68 Debug( LDAP_DEBUG_ANY,
69 "monitor_subsys_listener_init: "
70 "unable to get listeners\n", 0, 0, 0 );
76 for ( i = 0; l[i]; i++ );
78 char buf[ BACKMONITOR_BUFSIZE ];
80 snprintf( buf, sizeof( buf ),
81 "dn: cn=Listener %d,%s\n"
83 "structuralObjectClass: %s\n"
87 "createTimestamp: %s\n"
88 "modifyTimestamp: %s\n",
90 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_dn.bv_val,
91 mi->mi_oc_monitoredObject->soc_cname.bv_val,
92 mi->mi_oc_monitoredObject->soc_cname.bv_val,
94 mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
97 mi->mi_startTime.bv_val,
98 mi->mi_startTime.bv_val );
100 e = str2entry( buf );
103 LDAP_LOG( OPERATION, CRIT,
104 "monitor_subsys_listener_init: "
105 "unable to create entry 'cn=Listener, %d,%s'\n",
106 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
108 Debug( LDAP_DEBUG_ANY,
109 "monitor_subsys_listener_init: "
110 "unable to create entry 'cn=Listener %d,%s'\n%s",
112 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
119 if ( l[i]->sl_is_tls ) {
123 bv.bv_len = sizeof("TLS")-1;
125 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
128 #endif /* HAVE_TLS */
129 #ifdef LDAP_CONNECTIONLESS
130 if ( l[i]->sl_is_udp ) {
134 bv.bv_len = sizeof("UDP")-1;
136 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
139 #endif /* HAVE_TLS */
141 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
142 e->e_private = ( void * )mp;
144 mp->mp_children = NULL;
145 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_LISTENER];
146 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_LISTENER].mss_flags
149 if ( monitor_cache_add( mi, e ) ) {
151 LDAP_LOG( OPERATION, CRIT,
152 "monitor_subsys_listener_init: "
153 "unable to add entry 'cn=Listener %d,%s'\n",
154 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
156 Debug( LDAP_DEBUG_ANY,
157 "monitor_subsys_listener_init: "
158 "unable to add entry 'cn=Listener %d,%s'\n",
160 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
169 mp = ( struct monitorentrypriv * )e_listener->e_private;
170 mp->mp_children = e_tmp;
172 monitor_cache_release( mi, e_listener );