1 /* listener.c - deals with listener subsystem */
3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
9 * This work has beed deveolped for the OpenLDAP Foundation
10 * in the hope that it may be useful to the Open Source community,
11 * but WITHOUT ANY WARRANTY.
13 * Permission is granted to anyone to use this software for any purpose
14 * on any computer system, and to alter it and redistribute it, subject
15 * to the following restrictions:
17 * 1. The author and SysNet s.n.c. are not responsible for the consequences
18 * of use of this software, no matter how awful, even if they arise from
21 * 2. The origin of this software must not be misrepresented, either by
22 * explicit claim or by omission. Since few users ever read sources,
23 * credits should appear in the documentation.
25 * 3. Altered versions must be plainly marked as such, and must not be
26 * misrepresented as being the original software. Since few users
27 * ever read sources, credits should appear in the documentation.
28 * SysNet s.n.c. cannot be responsible for the consequences of the
31 * 4. This notice may not be removed or altered.
39 #include "back-monitor.h"
42 monitor_subsys_listener_init(
46 struct monitorinfo *mi;
47 Entry *e, *e_listener, *e_tmp;
49 struct monitorentrypriv *mp;
54 mi = ( struct monitorinfo * )be->be_private;
56 if ( monitor_cache_get( mi,
57 &monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn,
60 LDAP_LOG( OPERATION, CRIT,
61 "monitor_subsys_listener_init: "
62 "unable to get entry '%s'\n",
63 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0, 0 );
65 Debug( LDAP_DEBUG_ANY,
66 "monitor_subsys_listener_init: "
67 "unable to get entry '%s'\n%s%s",
68 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
74 if ( ( l = slapd_get_listeners() ) == NULL ) {
76 LDAP_LOG( OPERATION, CRIT,
77 "monitor_subsys_listener_init: "
78 "unable to get listeners\n", 0, 0, 0 );
80 Debug( LDAP_DEBUG_ANY,
81 "monitor_subsys_listener_init: "
82 "unable to get listeners\n", 0, 0, 0 );
88 for ( i = 0; l[i]; i++ );
90 char buf[ BACKMONITOR_BUFSIZE ];
92 snprintf( buf, sizeof( buf ),
93 "dn: cn=Listener %d,%s\n"
95 "structuralObjectClass: %s\n"
99 "createTimestamp: %s\n"
100 "modifyTimestamp: %s\n",
102 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_dn.bv_val,
103 mi->mi_oc_monitoredObject->soc_cname.bv_val,
104 mi->mi_oc_monitoredObject->soc_cname.bv_val,
106 mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
107 l[i]->sl_name.bv_val,
109 mi->mi_startTime.bv_val,
110 mi->mi_startTime.bv_val );
112 e = str2entry( buf );
115 LDAP_LOG( OPERATION, CRIT,
116 "monitor_subsys_listener_init: "
117 "unable to create entry 'cn=Listener, %d,%s'\n",
118 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
120 Debug( LDAP_DEBUG_ANY,
121 "monitor_subsys_listener_init: "
122 "unable to create entry 'cn=Listener %d,%s'\n%s",
124 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
131 if ( l[i]->sl_is_tls ) {
135 bv.bv_len = sizeof("TLS")-1;
137 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
140 #endif /* HAVE_TLS */
141 #ifdef LDAP_CONNECTIONLESS
142 if ( l[i]->sl_is_udp ) {
146 bv.bv_len = sizeof("UDP")-1;
148 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
151 #endif /* HAVE_TLS */
153 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
154 e->e_private = ( void * )mp;
156 mp->mp_children = NULL;
157 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_LISTENER];
158 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_LISTENER].mss_flags
161 if ( monitor_cache_add( mi, e ) ) {
163 LDAP_LOG( OPERATION, CRIT,
164 "monitor_subsys_listener_init: "
165 "unable to add entry 'cn=Listener %d,%s'\n",
166 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
168 Debug( LDAP_DEBUG_ANY,
169 "monitor_subsys_listener_init: "
170 "unable to add entry 'cn=Listener %d,%s'\n",
172 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
181 mp = ( struct monitorentrypriv * )e_listener->e_private;
182 mp->mp_children = e_tmp;
184 monitor_cache_release( mi, e_listener );