A better find_connection() port fix

This commit is contained in:
Kurt Zeilenga 2004-08-28 03:53:31 +00:00
parent 1d3eccca9e
commit 8064bb6ef1
3 changed files with 38 additions and 2 deletions

View 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 )

View 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

View 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 )
{