1 /* listener.c - deals with listener subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2005 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(
36 Entry *e_listener, **ep;
43 if ( ( l = slapd_get_listeners() ) == NULL ) {
44 if ( slapMode & SLAP_TOOL_MODE ) {
48 Debug( LDAP_DEBUG_ANY,
49 "monitor_subsys_listener_init: "
50 "unable to get listeners\n", 0, 0, 0 );
54 mi = ( monitor_info_t * )be->be_private;
56 if ( monitor_cache_get( mi, &ms->mss_ndn, &e_listener ) ) {
57 Debug( LDAP_DEBUG_ANY,
58 "monitor_subsys_listener_init: "
59 "unable to get entry \"%s\"\n",
60 ms->mss_ndn.bv_val, 0, 0 );
64 mp = ( monitor_entry_t * )e_listener->e_private;
65 mp->mp_children = NULL;
66 ep = &mp->mp_children;
68 for ( i = 0; l[ i ]; i++ ) {
69 char buf[ BACKMONITOR_BUFSIZE ];
72 snprintf( buf, sizeof( buf ),
73 "dn: cn=Listener %d,%s\n"
75 "structuralObjectClass: %s\n"
81 "createTimestamp: %s\n"
82 "modifyTimestamp: %s\n",
85 mi->mi_oc_monitoredObject->soc_cname.bv_val,
86 mi->mi_oc_monitoredObject->soc_cname.bv_val,
88 mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
89 l[ i ]->sl_name.bv_val,
90 l[ i ]->sl_url.bv_val,
91 mi->mi_creatorsName.bv_val,
92 mi->mi_creatorsName.bv_val,
93 mi->mi_startTime.bv_val,
94 mi->mi_startTime.bv_val );
98 Debug( LDAP_DEBUG_ANY,
99 "monitor_subsys_listener_init: "
100 "unable to create entry \"cn=Listener %d,%s\"\n",
101 i, ms->mss_ndn.bv_val, 0 );
106 if ( l[ i ]->sl_is_tls ) {
110 bv.bv_len = sizeof("TLS")-1;
112 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
115 #endif /* HAVE_TLS */
116 #ifdef LDAP_CONNECTIONLESS
117 if ( l[ i ]->sl_is_udp ) {
120 BER_BVSTR( &bv, "UDP" );
121 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
124 #endif /* HAVE_TLS */
126 mp = monitor_entrypriv_create();
130 e->e_private = ( void * )mp;
132 mp->mp_flags = ms->mss_flags
135 if ( monitor_cache_add( mi, e ) ) {
136 Debug( LDAP_DEBUG_ANY,
137 "monitor_subsys_listener_init: "
138 "unable to add entry \"cn=Listener %d,%s\"\n",
139 i, ms->mss_ndn.bv_val, 0 );
147 monitor_cache_release( mi, e_listener );