]> git.sur5r.net Git - openldap/commitdiff
ITS#4414: SLP attributes support from Peter Marschall
authorKurt Zeilenga <kurt@openldap.org>
Thu, 27 Apr 2006 19:36:40 +0000 (19:36 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 27 Apr 2006 19:36:40 +0000 (19:36 +0000)
doc/man/man8/slapd.8
servers/slapd/daemon.c
servers/slapd/main.c
servers/slapd/proto-slap.h

index df0a82a9eef545ce483ce7f081331e5b48f1d9a9..96e1d9edb649075fc7261ab5eec214413650ddbf 100644 (file)
@@ -13,6 +13,7 @@ slapd \- Stand-alone LDAP Daemon
 .B [\-F slapd\-config\-directory]
 .B [\-h URLs]
 .B [\-n service\-name] [\-s syslog\-level] [\-l syslog\-local\-user]
+.B [\-o option[=value]]
 .B [\-r directory]
 .B [\-u user] [\-g group]
 .B [\-c cookie]
@@ -236,6 +237,30 @@ must be provided in order for any other specified values to be used.
 is the commit sequence number received by a previous synchronization
 and represents the state of the consumer replica content which the
 syncrepl engine will synchronize to the current provider content.
+.TP
+.BI \-o " option[=value]"
+This option provides a generic means to specify options without the need to reserve
+a separate letter for them.
+
+It supports the following options:
+.RS
+.TP
+slp={\fBon\fP|\fBoff\fP|\fIslp\-attrs\fP}
+When SLP support is compiled into slapd, disable it (
+.B off
+), enable it by registering at SLP DAs without specific SLP attributes (
+.B on
+), or with specific SLP attributes
+.I slp\-attrs
+that must be an SLP attribute list definition according to the SLP standard.
+
+For example, "-o slp=(tree=production),(server-type=OpenLDAP),(server-version=2.3.20)"
+registers at SLP DAs with the three SLP attributes tree, server-type and server-version
+that have the values given above.
+This allows to specifically query the SLP DAs for LDAP servers holding the
+.I production
+tree in case multiple trees are availabe.
+.RE
 .SH EXAMPLES
 To start 
 .I slapd
index 4f6875ff78ef79ebd5db8ba05065a56aa4ca3367..8d44358f4c124d29c59a863648b48693ae426ea0 100644 (file)
@@ -339,9 +339,13 @@ static struct slap_daemon {
 static char** slapd_srvurls = NULL;
 static SLPHandle slapd_hslp = 0;
 int slapd_register_slp = 0;
+char *slapd_slp_attrs = NULL;
+
+static SLPError slapd_slp_cookie;
 
 void slapd_slp_init( const char* urls ) {
        int i;
+       SLPError err;
 
        slapd_srvurls = ldap_str2charray( urls, " " );
 
@@ -376,7 +380,12 @@ void slapd_slp_init( const char* urls ) {
        }
 
        /* open the SLP handle */
-       SLPOpen( "en", 0, &slapd_hslp );
+       err = SLPOpen( "en", 0, &slapd_hslp );
+
+       if (err != SLP_OK) {
+               Debug( LDAP_DEBUG_CONNS, "daemon: SLPOpen() failed with %ld\n",
+                       (long)err, 0, 0 );
+       }
 }
 
 void slapd_slp_deinit() {
@@ -394,11 +403,13 @@ void slapd_slp_regreport(
        SLPError errcode,
        void* cookie )
 {
-       /* empty report */
+       /* return the error code in the cookie */
+       *(SLPError*)cookie = errcode; 
 }
 
 void slapd_slp_reg() {
        int i;
+       SLPError err;
 
        if( slapd_srvurls == NULL ) return;
 
@@ -408,28 +419,41 @@ void slapd_slp_reg() {
                    strncmp( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX,
                                sizeof( LDAPS_SRVTYPE_PREFIX ) - 1 ) == 0 )
                {
-                       SLPReg( slapd_hslp,
+                       err = SLPReg( slapd_hslp,
                                slapd_srvurls[i],
                                SLP_LIFETIME_MAXIMUM,
                                "ldap",
-                               "",
-                               1,
+                                       (slapd_slp_attrs) ? slapd_slp_attrs : "",
+                                       SLP_TRUE,
                                slapd_slp_regreport,
-                               NULL );
+                                       &slapd_slp_cookie );
+
+                       if (err != SLP_OK || slapd_slp_cookie != SLP_OK) {
+                               Debug( LDAP_DEBUG_CONNS,
+                                       "daemon: SLPReg(%s) failed with %ld, cookie = %ld\n",
+                                       slapd_srvurls[i], (long)err, (long)slapd_slp_cookie );
+                       }       
                }
        }
 }
 
 void slapd_slp_dereg() {
        int i;
+       SLPError err;
 
        if( slapd_srvurls == NULL ) return;
 
        for( i=0; slapd_srvurls[i] != NULL; i++ ) {
-               SLPDereg( slapd_hslp,
+               err = SLPDereg( slapd_hslp,
                        slapd_srvurls[i],
                        slapd_slp_regreport,
-                       NULL );
+                               &slapd_slp_cookie );
+               
+               if (err != SLP_OK || slapd_slp_cookie != SLP_OK) {
+                       Debug( LDAP_DEBUG_CONNS,
+                               "daemon: SLPDereg(%s) failed with %ld, cookie = %ld\n",
+                               slapd_srvurls[i], (long)err, (long)slapd_slp_cookie );
+               }
        }
 }
 #endif /* HAVE_SLP */
index 76f30adf45729f19e83df3deaafcd10881dc1dc2..eb475f2f08dea9ba0bc131693688922a65fc86c0 100644 (file)
@@ -115,8 +115,9 @@ slapd_opt_slp( const char *val, void *arg )
 {
 #ifdef HAVE_SLP
        /* NULL is default */
-       if ( val == NULL || strcasecmp( val, "on" ) == 0 ) {
+       if ( val == NULL || *val == '(' || strcasecmp( val, "on" ) == 0 ) {
                slapd_register_slp = 1;
+               slapd_slp_attrs = (val != NULL && *val == '(') ? val : NULL;
 
        } else if ( strcasecmp( val, "off" ) == 0 ) {
                slapd_register_slp = 0;
@@ -155,7 +156,7 @@ struct option_helper {
        void            *oh_arg;
        const char      *oh_usage;
 } option_helpers[] = {
-       { BER_BVC("slp"),       slapd_opt_slp,  NULL, "slp[={on|off}] enable/disable SLP" },
+       { BER_BVC("slp"),       slapd_opt_slp,  NULL, "slp[={on|off|(attrs)}] enable/disable SLP using (attrs)" },
        { BER_BVNULL, 0, NULL, NULL }
 };
 
index 3697dad902fabe5554ff441b9523dcdc5abc7936..5a8bb9c5d605d6d7f086a0ee800a747e5e7dfabb 100644 (file)
@@ -727,6 +727,7 @@ LDAP_SLAPD_F (int) slapd_clr_read LDAP_P((ber_socket_t s, int wake));
 LDAP_SLAPD_V (volatile sig_atomic_t) slapd_abrupt_shutdown;
 LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown;
 LDAP_SLAPD_V (int) slapd_register_slp;
+LDAP_SLAPD_V (char *) slapd_slp_attrs;
 LDAP_SLAPD_V (slap_ssf_t) local_ssf;
 LDAP_SLAPD_V (struct runqueue_s) slapd_rq;