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"
89 "createTimestamp: %s\n"
90 "modifyTimestamp: %s\n",
92 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_dn.bv_val,
93 mi->mi_oc_monitoredObject->soc_cname.bv_val,
94 mi->mi_oc_monitoredObject->soc_cname.bv_val,
96 mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
99 mi->mi_creatorsName.bv_val,
100 mi->mi_creatorsName.bv_val,
101 mi->mi_startTime.bv_val,
102 mi->mi_startTime.bv_val );
104 e = str2entry( buf );
107 LDAP_LOG( OPERATION, CRIT,
108 "monitor_subsys_listener_init: "
109 "unable to create entry 'cn=Listener, %d,%s'\n",
110 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
112 Debug( LDAP_DEBUG_ANY,
113 "monitor_subsys_listener_init: "
114 "unable to create entry 'cn=Listener %d,%s'\n%s",
116 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
123 if ( l[i]->sl_is_tls ) {
127 bv.bv_len = sizeof("TLS")-1;
129 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
132 #endif /* HAVE_TLS */
133 #ifdef LDAP_CONNECTIONLESS
134 if ( l[i]->sl_is_udp ) {
138 bv.bv_len = sizeof("UDP")-1;
140 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
143 #endif /* HAVE_TLS */
145 mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
146 e->e_private = ( void * )mp;
148 mp->mp_children = NULL;
149 mp->mp_info = &monitor_subsys[SLAPD_MONITOR_LISTENER];
150 mp->mp_flags = monitor_subsys[SLAPD_MONITOR_LISTENER].mss_flags
153 if ( monitor_cache_add( mi, e ) ) {
155 LDAP_LOG( OPERATION, CRIT,
156 "monitor_subsys_listener_init: "
157 "unable to add entry 'cn=Listener %d,%s'\n",
158 i, monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val, 0 );
160 Debug( LDAP_DEBUG_ANY,
161 "monitor_subsys_listener_init: "
162 "unable to add entry 'cn=Listener %d,%s'\n",
164 monitor_subsys[SLAPD_MONITOR_LISTENER].mss_ndn.bv_val,
173 mp = ( struct monitorentrypriv * )e_listener->e_private;
174 mp->mp_children = e_tmp;
176 monitor_cache_release( mi, e_listener );