1 /* listener.c - deals with listener subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2003 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masarati for inclusion
18 * in OpenLDAP Software.
20 /* This is an altered version */
22 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
24 * This work has beed deveolped for the OpenLDAP Foundation
25 * in the hope that it may be useful to the Open Source community,
26 * but WITHOUT ANY WARRANTY.
28 * Permission is granted to anyone to use this software for any purpose
29 * on any computer system, and to alter it and redistribute it, subject
30 * to the following restrictions:
32 * 1. The author and SysNet s.n.c. are not responsible for the consequences
33 * of use of this software, no matter how awful, even if they arise from
36 * 2. The origin of this software must not be misrepresented, either by
37 * explicit claim or by omission. Since few users ever read sources,
38 * credits should appear in the documentation.
40 * 3. Altered versions must be plainly marked as such, and must not be
41 * misrepresented as being the original software. Since few users
42 * ever read sources, credits should appear in the documentation.
43 * SysNet s.n.c. cannot be responsible for the consequences of the
46 * 4. This notice may not be removed or altered.
54 #include "back-monitor.h"
57 monitor_subsys_listener_init(
61 struct monitorinfo *mi;
62 Entry *e, *e_listener, *e_tmp;
64 struct monitorentrypriv *mp;
69 mi = ( struct monitorinfo * )be->be_private;
71 if ( monitor_cache_get( mi,
72 &monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn,
75 LDAP_LOG( OPERATION, CRIT,
76 "monitor_subsys_listener_init: "
77 "unable to get entry '%s'\n",
78 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0, 0 );
80 Debug( LDAP_DEBUG_ANY,
81 "monitor_subsys_listener_init: "
82 "unable to get entry '%s'\n%s%s",
83 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
89 if ( ( l = slapd_get_listeners() ) == NULL ) {
91 LDAP_LOG( OPERATION, CRIT,
92 "monitor_subsys_listener_init: "
93 "unable to get listeners\n", 0, 0, 0 );
95 Debug( LDAP_DEBUG_ANY,
96 "monitor_subsys_listener_init: "
97 "unable to get listeners\n", 0, 0, 0 );
103 for ( i = 0; l[i]; i++ );
105 char buf[ BACKMONITOR_BUFSIZE ];
107 snprintf( buf, sizeof( buf ),
108 "dn: cn=Listener %d,%s\n"
110 "structuralObjectClass: %s\n"
114 "createTimestamp: %s\n"
115 "modifyTimestamp: %s\n",
117 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_dn.bv_val,
118 mi->mi_oc_monitoredObject->soc_cname.bv_val,
119 mi->mi_oc_monitoredObject->soc_cname.bv_val,
121 mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
122 l[i]->sl_name.bv_val,
124 mi->mi_startTime.bv_val,
125 mi->mi_startTime.bv_val );
127 e = str2entry( buf );
130 LDAP_LOG( OPERATION, CRIT,
131 "monitor_subsys_listener_init: "
132 "unable to create entry 'cn=Listener, %d,%s'\n",
133 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
135 Debug( LDAP_DEBUG_ANY,
136 "monitor_subsys_listener_init: "
137 "unable to create entry 'cn=Listener %d,%s'\n%s",
139 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
146 if ( l[i]->sl_is_tls ) {
150 bv.bv_len = sizeof("TLS")-1;
152 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
155 #endif /* HAVE_TLS */
156 #ifdef LDAP_CONNECTIONLESS
157 if ( l[i]->sl_is_udp ) {
161 bv.bv_len = sizeof("UDP")-1;
163 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
166 #endif /* HAVE_TLS */
168 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
169 e->e_private = ( void * )mp;
171 mp->mp_children = NULL;
172 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_LISTENER];
173 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_LISTENER].mss_flags
176 if ( monitor_cache_add( mi, e ) ) {
178 LDAP_LOG( OPERATION, CRIT,
179 "monitor_subsys_listener_init: "
180 "unable to add entry 'cn=Listener %d,%s'\n",
181 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
183 Debug( LDAP_DEBUG_ANY,
184 "monitor_subsys_listener_init: "
185 "unable to add entry 'cn=Listener %d,%s'\n",
187 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
196 mp = ( struct monitorentrypriv * )e_listener->e_private;
197 mp->mp_children = e_tmp;
199 monitor_cache_release( mi, e_listener );