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.
25 #include <ac/string.h>
28 #include "back-monitor.h"
31 monitor_subsys_listener_init(
37 Entry *e_listener, **ep;
44 if ( ( l = slapd_get_listeners() ) == NULL ) {
45 if ( slapMode & SLAP_TOOL_MODE ) {
49 Debug( LDAP_DEBUG_ANY,
50 "monitor_subsys_listener_init: "
51 "unable to get listeners\n", 0, 0, 0 );
55 mi = ( monitor_info_t * )be->be_private;
57 if ( monitor_cache_get( mi, &ms->mss_ndn, &e_listener ) ) {
58 Debug( LDAP_DEBUG_ANY,
59 "monitor_subsys_listener_init: "
60 "unable to get entry \"%s\"\n",
61 ms->mss_ndn.bv_val, 0, 0 );
65 mp = ( monitor_entry_t * )e_listener->e_private;
66 mp->mp_children = NULL;
67 ep = &mp->mp_children;
69 for ( i = 0; l[ i ]; i++ ) {
70 char buf[ BACKMONITOR_BUFSIZE ];
73 snprintf( buf, sizeof( buf ),
74 "dn: cn=Listener %d,%s\n"
76 "structuralObjectClass: %s\n"
82 "createTimestamp: %s\n"
83 "modifyTimestamp: %s\n",
86 mi->mi_oc_monitoredObject->soc_cname.bv_val,
87 mi->mi_oc_monitoredObject->soc_cname.bv_val,
89 mi->mi_ad_monitorConnectionLocalAddress->ad_cname.bv_val,
90 l[ i ]->sl_name.bv_val,
91 l[ i ]->sl_url.bv_val,
92 mi->mi_creatorsName.bv_val,
93 mi->mi_creatorsName.bv_val,
94 mi->mi_startTime.bv_val,
95 mi->mi_startTime.bv_val );
99 Debug( LDAP_DEBUG_ANY,
100 "monitor_subsys_listener_init: "
101 "unable to create entry \"cn=Listener %d,%s\"\n",
102 i, ms->mss_ndn.bv_val, 0 );
107 if ( l[ i ]->sl_is_tls ) {
110 BER_BVSTR( &bv, "TLS" );
111 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
114 #endif /* HAVE_TLS */
115 #ifdef LDAP_CONNECTIONLESS
116 if ( l[ i ]->sl_is_udp ) {
119 BER_BVSTR( &bv, "UDP" );
120 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
123 #endif /* HAVE_TLS */
125 mp = monitor_entrypriv_create();
129 e->e_private = ( void * )mp;
131 mp->mp_flags = ms->mss_flags
134 if ( monitor_cache_add( mi, e ) ) {
135 Debug( LDAP_DEBUG_ANY,
136 "monitor_subsys_listener_init: "
137 "unable to add entry \"cn=Listener %d,%s\"\n",
138 i, ms->mss_ndn.bv_val, 0 );
146 monitor_cache_release( mi, e_listener );