]> git.sur5r.net Git - openldap/commitdiff
A better find_connection() port fix
authorKurt Zeilenga <kurt@openldap.org>
Sat, 28 Aug 2004 03:53:31 +0000 (03:53 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 28 Aug 2004 03:53:31 +0000 (03:53 +0000)
include/ldap_pvt.h
libraries/libldap/request.c
libraries/libldap/url.c

index 8785f9ac1751a1c553927d38c9d3111fc17976ff..f218223acf8412280b08030362f66e741dd119ef 100644 (file)
@@ -35,6 +35,10 @@ LDAP_F ( int )
 ldap_pvt_url_scheme2tls LDAP_P((
        const char * ));
 
+LDAP_F ( int )
+ldap_pvt_url_scheme_port LDAP_P((
+       const char *, int ));
+
 struct ldap_url_desc; /* avoid pulling in <ldap.h> */
 
 LDAP_F( int )
index fec28e0d1cd164227c7fe675bfb94411345ee406..305dc945dd2b96da3f9bdd898f8b39076983cc9b 100644 (file)
@@ -452,9 +452,13 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
 
        for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
                lcu = lc->lconn_server;
-               lcu_port = lcu->lud_port ? lcu->lud_port : LDAP_PORT;
+               lcu_port = ldap_pvt_url_scheme_port( lcu->lud_scheme,
+                       lcu->lud_port );
+
                for ( lsu = srv; lsu != NULL; lsu = lsu->lud_next ) {
-                       lsu_port = lsu->lud_port ? lsu->lud_port : LDAP_PORT;
+                       lsu_port = ldap_pvt_url_scheme_port( lsu->lud_scheme,
+                               lsu->lud_port );
+
                        if ( lcu->lud_host != NULL && *lcu->lud_host != '\0'
                            && lsu->lud_host != NULL && *lsu->lud_host != '\0'
                                && strcasecmp( lsu->lud_host, lcu->lud_host ) == 0
index 6b520d5c4c9ae859cd227ca8be52f81dab5b1d78..a0f7dab38dd136607e23ad42bd8e899ce5905ec2 100644 (file)
@@ -78,6 +78,34 @@ int ldap_pvt_url_scheme2proto( const char *scheme )
        return -1;
 }
 
+int ldap_pvt_url_scheme_port( const char *scheme, int port )
+{
+       assert( scheme );
+
+       if( port ) return port;
+       if( scheme == NULL ) return port;
+
+       if( strcmp("ldap", scheme) == 0 ) {
+               return LDAP_PORT;
+       }
+
+       if( strcmp("ldapi", scheme) == 0 ) {
+               return -1;
+       }
+
+       if( strcmp("ldaps", scheme) == 0 ) {
+               return LDAPS_PORT;
+       }
+
+#ifdef LDAP_CONNECTIONLESS
+       if( strcmp("cldap", scheme) == 0 ) {
+               return LDAP_PORT;
+       }
+#endif
+
+       return -1;
+}
+
 int
 ldap_pvt_url_scheme2tls( const char *scheme )
 {