/* OpenLDAP TLS options */
#define LDAP_OPT_X_TLS 0x6000
-#define LDAP_OPT_X_TLS_CTX 0x6001 /* OpenSSL CTX */
+#define LDAP_OPT_X_TLS_CTX 0x6001 /* OpenSSL CTX* */
#define LDAP_OPT_X_TLS_CACERTFILE 0x6002
#define LDAP_OPT_X_TLS_CACERTDIR 0x6003
#define LDAP_OPT_X_TLS_CERTFILE 0x6004
/* #define LDAP_OPT_X_TLS_PROTOCOL 0x6007 */
#define LDAP_OPT_X_TLS_CIPHER_SUITE 0x6008
#define LDAP_OPT_X_TLS_RANDOM_FILE 0x6009
-#define LDAP_OPT_X_TLS_SSL_CTX 0x600a
+#define LDAP_OPT_X_TLS_SSL_CTX 0x600a /* OpenSSL SSL* */
#define LDAP_OPT_X_TLS_CRLCHECK 0x600b
#define LDAP_OPT_X_TLS_CONNECT_CB 0x600c
#define LDAP_OPT_X_TLS_CONNECT_ARG 0x600d
struct sockaddr;
/* Called after a connection is established */
-typedef void (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, const char *name, struct sockaddr *addr,
+typedef int (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, struct sockaddr *addr,
struct ldap_conncb *ctx ));
/* Called before a connection is closed */
typedef void (ldap_conn_del_f) LDAP_P(( LDAP *ld, Sockbuf *sb, struct ldap_conncb *ctx ));
LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest,
const struct timeval *tm );
LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb,
- int proto, const char *host, int port, int async );
+ int proto, LDAPURLDesc *srv, int async );
LDAP_F (int) ldap_int_poll( LDAP *ld, ber_socket_t s,
struct timeval *tvp );
LDAP_F (int) ldap_is_write_ready( LDAP *ld, Sockbuf *sb );
LDAP_F (int) ldap_int_connect_cbs( LDAP *ld, Sockbuf *sb,
- ber_socket_t *s, const char *name, struct sockaddr *addr );
+ ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr );
/*
* in os-local.c
*/
#ifdef LDAP_PF_LOCAL
LDAP_F (int) ldap_connect_to_path( LDAP *ld, Sockbuf *sb,
- const char *path, int async );
+ LDAPURLDesc *srv, int async );
#endif /* LDAP_PF_LOCAL */
/*
switch ( proto = ldap_pvt_url_scheme2proto( srv->lud_scheme ) ) {
case LDAP_PROTO_TCP:
- port = srv->lud_port;
-
- if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
- host = NULL;
- } else {
- host = srv->lud_host;
- }
-
- if( !port ) {
- if( strcmp(srv->lud_scheme, "ldaps") == 0 ) {
- port = LDAPS_PORT;
- } else {
- port = LDAP_PORT;
- }
- }
-
rc = ldap_connect_to_host( ld, conn->lconn_sb,
- proto, host, port, async );
+ proto, srv, async );
if ( rc == -1 ) return rc;
-
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
LBER_SBIOD_LEVEL_PROVIDER, (void *)"tcp_" );
#ifdef LDAP_CONNECTIONLESS
case LDAP_PROTO_UDP:
- port = srv->lud_port;
-
- if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
- host = NULL;
- } else {
- host = srv->lud_host;
- }
-
- if( !port ) port = LDAP_PORT;
-
LDAP_IS_UDP(ld) = 1;
rc = ldap_connect_to_host( ld, conn->lconn_sb,
- proto, host, port, async );
+ proto, srv, async );
if ( rc == -1 ) return rc;
#ifdef LDAP_DEBUG
#ifdef LDAP_PF_LOCAL
/* only IPC mechanism supported is PF_LOCAL (PF_UNIX) */
rc = ldap_connect_to_path( ld, conn->lconn_sb,
- srv->lud_host, async );
+ srv, async );
if ( rc == -1 ) return rc;
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
#endif
int
-ldap_int_connect_cbs(LDAP *ld, Sockbuf *sb, ber_socket_t *s, const char *host, struct sockaddr *addr)
+ldap_int_connect_cbs(LDAP *ld, Sockbuf *sb, ber_socket_t *s, LDAPURLDesc *srv, struct sockaddr *addr)
{
struct ldapoptions *lo;
ldaplist *ll;
lo = &ld->ld_options;
for (ll = lo->ldo_conn_cbs; ll; ll = ll->ll_next) {
cb = ll->ll_data;
- rc = cb->lc_add( ld, sb, host, addr, cb );
+ rc = cb->lc_add( ld, sb, srv, addr, cb );
/* on any failure, call the teardown functions for anything
* that previously succeeded
*/
lo = LDAP_INT_GLOBAL_OPT();
for (ll = lo->ldo_conn_cbs; ll; ll = ll->ll_next) {
cb = ll->ll_data;
- rc = cb->lc_add( ld, sb, host, addr, cb );
+ rc = cb->lc_add( ld, sb, srv, addr, cb );
if ( rc ) {
ldaplist *l2;
for (l2 = lo->ldo_conn_cbs; l2 != ll; l2 = l2->ll_next) {
int
ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
- int proto,
- const char *host, int port,
+ int proto, LDAPURLDesc *srv,
int async )
{
int rc;
- int socktype;
+ int socktype, port;
ber_socket_t s = AC_SOCKET_INVALID;
+ char *host;
#if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
char serv[7];
char *ha_buf=NULL;
#endif
- if( host == NULL ) host = "localhost";
-
+ if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
+ host = "localhost";
+ } else {
+ host = srv->lud_host;
+ }
+
+ port = srv->lud_port;
+
+ if( !port ) {
+ if( strcmp(srv->lud_scheme, "ldaps") == 0 ) {
+ port = LDAPS_PORT;
+ } else {
+ port = LDAP_PORT;
+ }
+ }
+
switch(proto) {
case LDAP_PROTO_TCP: socktype = SOCK_STREAM;
osip_debug( ld,
rc = ldap_pvt_connect( ld, s,
sai->ai_addr, sai->ai_addrlen, async );
if ( rc == 0 || rc == -2 ) {
- err = ldap_int_connect_cbs( ld, sb, &s, host, sai->ai_addr );
+ err = ldap_int_connect_cbs( ld, sb, &s, srv, sai->ai_addr );
if ( err )
rc = err;
else
async);
if ( (rc == 0) || (rc == -2) ) {
- i = ldap_int_connect_cbs( ld, sb, &s, host, (struct sockaddr *)&sin );
+ i = ldap_int_connect_cbs( ld, sb, &s, srv, (struct sockaddr *)&sin );
if ( i )
rc = i;
else
}
int
-ldap_connect_to_path(LDAP *ld, Sockbuf *sb, const char *path, int async)
+ldap_connect_to_path(LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, int async)
{
struct sockaddr_un server;
ber_socket_t s;
int rc;
+ const char *path = srv->lud_host;
oslocal_debug(ld, "ldap_connect_to_path\n",0,0,0);
if (rc == 0) {
int err;
- err = ldap_int_connect_cbs( ld, sb, &s, path, (struct sockaddr *)&server );
+ err = ldap_int_connect_cbs( ld, sb, &s, srv, (struct sockaddr *)&server );
if ( err )
rc = err;
}