1 /* listener.c - deals with listener subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2007 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 ];
74 bv.bv_len = snprintf( buf, sizeof( buf ),
75 "cn=Listener %d", i );
77 e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, &bv,
78 mi->mi_oc_monitoredObject, mi, NULL, NULL );
81 Debug( LDAP_DEBUG_ANY,
82 "monitor_subsys_listener_init: "
83 "unable to create entry \"cn=Listener %d,%s\"\n",
84 i, ms->mss_ndn.bv_val, 0 );
88 attr_merge_normalize_one( e, mi->mi_ad_monitorConnectionLocalAddress,
89 &l[ i ]->sl_name, NULL );
91 attr_merge_normalize_one( e, slap_schema.si_ad_labeledURI,
92 &l[ i ]->sl_url, NULL );
95 if ( l[ i ]->sl_is_tls ) {
98 BER_BVSTR( &bv, "TLS" );
99 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
102 #endif /* HAVE_TLS */
103 #ifdef LDAP_CONNECTIONLESS
104 if ( l[ i ]->sl_is_udp ) {
107 BER_BVSTR( &bv, "UDP" );
108 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
111 #endif /* HAVE_TLS */
113 mp = monitor_entrypriv_create();
117 e->e_private = ( void * )mp;
119 mp->mp_flags = ms->mss_flags
122 if ( monitor_cache_add( mi, e ) ) {
123 Debug( LDAP_DEBUG_ANY,
124 "monitor_subsys_listener_init: "
125 "unable to add entry \"cn=Listener %d,%s\"\n",
126 i, ms->mss_ndn.bv_val, 0 );
134 monitor_cache_release( mi, e_listener );