/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
LDAP *ld, struct sockaddr *sap ));
static int cldap_result LDAP_P((
LDAP *ld, int msgid, LDAPMessage **res,
LDAP *ld, struct sockaddr *sap ));
static int cldap_result LDAP_P((
LDAP *ld, int msgid, LDAPMessage **res,
static int cldap_parsemsg LDAP_P((
LDAP *ld, int msgid, BerElement *ber,
static int cldap_parsemsg LDAP_P((
LDAP *ld, int msgid, BerElement *ber,
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
sock.sin_family = AF_INET;
sock.sin_port = 0;
if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
sock.sin_family = AF_INET;
sock.sin_port = 0;
if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
- ldap_ld_free(ld, 1);
- return( NULL );
- }
- ld->ld_sb.sb_sd = s;
- ld->ld_sb.sb_naddr = 0;
- ld->ld_version = LDAP_VERSION;
+ if (ber_pvt_sb_set_io( &(ld->ld_sb), &ber_pvt_sb_io_udp, NULL )<0) {
+ ldap_ld_free(ld, 1, NULL, NULL );
+ return NULL;
+ }
+
+ ld->ld_version = LDAP_VERSION2;
for ( ; host != NULL; host = p ) {
if (( p = strchr( host, ' ' )) != NULL ) {
for (*p++ = '\0'; *p == ' '; p++) {
for ( ; host != NULL; host = p ) {
if (( p = strchr( host, ' ' )) != NULL ) {
for (*p++ = '\0'; *p == ' '; p++) {
/* This was just a test for -1 until OSF1 let inet_addr return
unsigned int, which is narrower than 'unsigned long address' */
if ( address == 0xffffffff || address == (unsigned long) -1 ) {
/* This was just a test for -1 until OSF1 let inet_addr return
unsigned int, which is narrower than 'unsigned long address' */
if ( address == 0xffffffff || address == (unsigned long) -1 ) {
- if ((ldap_int_gethostbyname_a( host, &he_buf, &ha_buf,
+ if ((ldap_pvt_gethostbyname_a( host, &he_buf, &ha_buf,
(char *)hp->h_addr_list[ i ],
sizeof(sock.sin_addr.s_addr));
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
(char *)hp->h_addr_list[ i ],
sizeof(sock.sin_addr.s_addr));
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
} else {
sock.sin_addr.s_addr = address;
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
} else {
sock.sin_addr.s_addr = address;
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
|| ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
|| ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
Debug( LDAP_DEBUG_TRACE, "end of cldap_open address %d is %s\n",
i, inet_ntoa( ((struct sockaddr_in *)
Debug( LDAP_DEBUG_TRACE, "end of cldap_open address %d is %s\n",
i, inet_ntoa( ((struct sockaddr_in *)
-cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
- int attrsonly, LDAPMessage **res, char *logdn )
+cldap_search_s( LDAP *ld,
+ LDAP_CONST char *base,
+ int scope,
+ LDAP_CONST char *filter,
+ char **attrs,
+ int attrsonly,
+ LDAPMessage **res,
+ char *logdn )
Debug( LDAP_DEBUG_TRACE, "cldap_search_s try %d (to %s)\n",
cri.cri_try, inet_ntoa( ((struct sockaddr_in *)
Debug( LDAP_DEBUG_TRACE, "cldap_search_s try %d (to %s)\n",
cri.cri_try, inet_ntoa( ((struct sockaddr_in *)
if ( (msgid = ldap_search( ld, base, scope, filter, attrs,
attrsonly )) == -1 ) {
if ( (msgid = ldap_search( ld, base, scope, filter, attrs,
attrsonly )) == -1 ) {
-
- if ( ld->ld_sb.sb_naddr == 0 ) {
- addrs = (struct sockaddr **)malloc( sizeof(struct sockaddr *));
- } else {
- addrs = (struct sockaddr **)realloc( ld->ld_sb.sb_addrs,
- ( ld->ld_sb.sb_naddr + 1 ) * sizeof(struct sockaddr *));
- }
+
+ addrs = (struct sockaddr **)LDAP_REALLOC( ld->ld_cldapaddrs,
+ ( ld->ld_cldapnaddr + 1 ) * sizeof(struct sockaddr *));
ld->ld_errno = LDAP_NO_MEMORY;
return( -1 );
}
SAFEMEMCPY( (char *)newsap, (char *)sap, sizeof( struct sockaddr ));
ld->ld_errno = LDAP_NO_MEMORY;
return( -1 );
}
SAFEMEMCPY( (char *)newsap, (char *)sap, sizeof( struct sockaddr ));
return( 0 );
}
static int
cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
return( 0 );
}
static int
cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
crip->cri_timeout = ld->ld_cldaptimeout;
crip->cri_useaddr = 0;
Debug( LDAP_DEBUG_TRACE, "cldap_result tries %d timeout %d\n",
ld->ld_cldaptries, ld->ld_cldaptimeout, 0 );
}
crip->cri_timeout = ld->ld_cldaptimeout;
crip->cri_useaddr = 0;
Debug( LDAP_DEBUG_TRACE, "cldap_result tries %d timeout %d\n",
ld->ld_cldaptries, ld->ld_cldaptimeout, 0 );
}
logdn = NULL;
if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
logdn = NULL;
if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
ret = LDAP_DECODING_ERROR;
Debug( LDAP_DEBUG_TRACE,
"cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
ret, 0, 0 );
} else if ( id != msgid ) {
ret = LDAP_DECODING_ERROR;
Debug( LDAP_DEBUG_TRACE,
"cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
ret, 0, 0 );
} else if ( id != msgid ) {
Debug( LDAP_DEBUG_TRACE,
"cldap_result: looking for msgid %d; got %d\n",
msgid, id, 0 );
ret = -1; /* ignore and keep looking */
} else {
Debug( LDAP_DEBUG_TRACE,
"cldap_result: looking for msgid %d; got %d\n",
msgid, id, 0 );
ret = -1; /* ignore and keep looking */
} else {
- sb->sb_addrs[ fromaddr ])->sin_addr,
- &((struct sockaddr_in *)sb->sb_fromaddr)->sin_addr,
+ ld->ld_cldapaddrs[ fromaddr ])->sin_addr,
+ &(src->sin_addr),
sizeof( struct in_addr )) == 0 ) {
break;
}
}
ret = cldap_parsemsg( ld, msgid, &ber, res, base );
sizeof( struct in_addr )) == 0 ) {
break;
}
}
ret = cldap_parsemsg( ld, msgid, &ber, res, base );
Debug( LDAP_DEBUG_TRACE,
"cldap_result got result (%d)\n", ret, 0, 0 );
}
if ( logdn != NULL ) {
Debug( LDAP_DEBUG_TRACE,
"cldap_result got result (%d)\n", ret, 0, 0 );
}
if ( logdn != NULL ) {
Debug( LDAP_DEBUG_TRACE, "cldap_result abandoning id %d (to %s)\n",
msgid, inet_ntoa( ((struct sockaddr_in *)
Debug( LDAP_DEBUG_TRACE, "cldap_result abandoning id %d (to %s)\n",
msgid, inet_ntoa( ((struct sockaddr_in *)
static int
cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
static int
cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
char *dn, *p, *cookie;
LDAPMessage *chain, *prev, *ldm;
struct berval *bv;
rc = LDAP_DECODING_ERROR; /* pessimistic */
char *dn, *p, *cookie;
LDAPMessage *chain, *prev, *ldm;
struct berval *bv;
rc = LDAP_DECODING_ERROR; /* pessimistic */
baselen = ( base == NULL ) ? 0 : strlen( base );
bv = NULL;
for ( tag = ber_first_element( ber, &len, &cookie );
tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
tag = ber_next_element( ber, &len, cookie )) {
baselen = ( base == NULL ) ? 0 : strlen( base );
bv = NULL;
for ( tag = ber_first_element( ber, &len, &cookie );
tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
tag = ber_next_element( ber, &len, cookie )) {
- if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val,
- bv->bv_len ) == -1 ) {
+ if ( ber_printf( ldm->lm_ber, "tO", tag, bv ) == -1 ) {
- if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) {
+ if ( ber_scanf( ber, "{aO" /*}*/, &dn, &bv ) == LBER_ERROR ) {
break; /* return w/error */
}
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
break; /* return w/error */
}
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
break; /* return w/error */
}
strcpy( p, dn );
strcpy( p + slen - 1, base );
break; /* return w/error */
}
strcpy( p, dn );
strcpy( p + slen - 1, base );
- fprintf( stderr, "cldap_parsemsg add message id %d type %d:\n",
- ldm->lm_msgid, ldm->lm_msgtype );
- lber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 );
+ fprintf( stderr, "cldap_parsemsg add message id %ld type %ld:\n",
+ (long) ldm->lm_msgid, (long) ldm->lm_msgtype );
+ ber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 );