*
* All I/O at this level must be atomic. For ease of use, the sb_readahead
* must be used above this module. All data reads and writes are prefixed
- * with a sockaddr containing the address of the remote entity. Upper levels
- * must read and write this sockaddr before doing the usual ber_printf/scanf
+ * with a sockaddr_storage containing the address of the remote entity. Upper levels
+ * must read and write this sockaddr_storage before doing the usual ber_printf/scanf
* operations on LDAP messages.
*/
assert( SOCKBUF_VALID( sbiod->sbiod_sb ) );
assert( buf != NULL );
- addrlen = sizeof( struct sockaddr );
+ addrlen = sizeof( struct sockaddr_storage );
src = buf;
buf = (char *) buf + addrlen;
len -= addrlen;
rc = recvfrom( sbiod->sbiod_sb->sb_fd, buf, len, 0, src, &addrlen );
- return rc > 0 ? rc+sizeof(struct sockaddr) : rc;
+ return rc > 0 ? rc+sizeof(struct sockaddr_storage) : rc;
}
static ber_slen_t
assert( buf != NULL );
dst = buf;
- buf = (char *) buf + sizeof( struct sockaddr );
- len -= sizeof( struct sockaddr );
+ buf = (char *) buf + sizeof( struct sockaddr_storage );
+ len -= sizeof( struct sockaddr_storage );
rc = sendto( sbiod->sbiod_sb->sb_fd, buf, len, 0, dst,
- sizeof( struct sockaddr ) );
+ sizeof( struct sockaddr_storage ) );
if ( rc < 0 ) return -1;
# endif
return -1;
}
- rc = len + sizeof(struct sockaddr);
+ rc = len + sizeof(struct sockaddr_storage);
return rc;
}
LDAP_NEXT_MSGID(ld, i);
#ifdef LDAP_CONNECTIONLESS
if ( LDAP_IS_UDP(ld) ) {
- struct sockaddr sa = {0};
+ struct sockaddr_storage sa = {0};
/* dummy, filled with ldo_peer in request.c */
err = ber_write( ber, (char *) &sa, sizeof(sa), 0 );
}
LDAP_IS_UDP(ld) = 1;
if( ld->ld_options.ldo_peer )
ldap_memfree( ld->ld_options.ldo_peer );
- ld->ld_options.ldo_peer = ldap_memalloc( sizeof( struct sockaddr ) );
- len = sizeof( struct sockaddr );
+ ld->ld_options.ldo_peer = ldap_memcalloc( 1, sizeof( struct sockaddr_storage ) );
+ len = sizeof( struct sockaddr_storage );
if( getpeername ( fd, ld->ld_options.ldo_peer, &len ) < 0) {
ldap_unbind_ext( ld, NULL, NULL );
return( AC_SOCKET_ERROR );
if (LDAP_IS_UDP(ld)) {
if (ld->ld_options.ldo_peer)
ldap_memfree(ld->ld_options.ldo_peer);
- ld->ld_options.ldo_peer=ldap_memalloc(sizeof(struct sockaddr));
- AC_MEMCPY(ld->ld_options.ldo_peer,sin,sizeof(struct sockaddr));
+ ld->ld_options.ldo_peer=ldap_memcalloc(1, sizeof(struct sockaddr_storage));
+ AC_MEMCPY(ld->ld_options.ldo_peer,sin,addrlen);
return ( 0 );
}
#endif
ber_rewind( &tmpber );
LDAP_MUTEX_LOCK( &ld->ld_options.ldo_mutex );
rc = ber_write( &tmpber, ld->ld_options.ldo_peer,
- sizeof( struct sockaddr ), 0 );
+ sizeof( struct sockaddr_storage ), 0 );
LDAP_MUTEX_UNLOCK( &ld->ld_options.ldo_mutex );
if ( rc == -1 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
sock_errset(0);
#ifdef LDAP_CONNECTIONLESS
if ( LDAP_IS_UDP(ld) ) {
- struct sockaddr from;
- ber_int_sb_read( lc->lconn_sb, &from, sizeof(struct sockaddr) );
+ struct sockaddr_storage from;
+ ber_int_sb_read( lc->lconn_sb, &from, sizeof(struct sockaddr_storage) );
if ( ld->ld_options.ldo_version == LDAP_VERSION2 ) isv2 = 1;
}
nextresp3:
LDAP_NEXT_MSGID( ld, *idp );
#ifdef LDAP_CONNECTIONLESS
if ( LDAP_IS_UDP(ld) ) {
- struct sockaddr sa = {0};
+ struct sockaddr_storage sa = {0};
/* dummy, filled with ldo_peer in request.c */
err = ber_write( ber, (char *) &sa, sizeof( sa ), 0 );
}