Ejemplo n.º 1
0
static ber_slen_t
sb_debug_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
{
	ber_slen_t		ret;
	char ebuf[128];

	ret = LBER_SBIOD_WRITE_NEXT( sbiod, buf, len );
	if (sbiod->sbiod_sb->sb_debug & LDAP_DEBUG_PACKETS) {
		int err = sock_errno();
		if ( ret < 0 ) {
			ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
				"%swrite: want=%ld error=%s\n",
				(char *)sbiod->sbiod_pvt, (long)len,
				AC_STRERROR_R( err, ebuf, sizeof ebuf ) );
		} else {
			ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
				"%swrite: want=%ld, written=%ld\n",
				(char *)sbiod->sbiod_pvt, (long)len, (long)ret );
			ber_log_bprint( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug,
				(const char *)buf, ret );
		}
		sock_errset(err);
	}

	return ret;
}
Ejemplo n.º 2
0
ber_slen_t
ber_pvt_sb_do_write( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out )
{
	ber_len_t		to_go;
	ber_slen_t ret;

	assert( sbiod != NULL );
	assert( SOCKBUF_VALID( sbiod->sbiod_sb ) );

	to_go = buf_out->buf_end - buf_out->buf_ptr;
	assert( to_go > 0 );
   
	for(;;) {
		ret = LBER_SBIOD_WRITE_NEXT( sbiod, buf_out->buf_base +
			buf_out->buf_ptr, to_go );
#ifdef EINTR
		if ((ret<0) && (errno==EINTR)) continue;
#endif
		break;
	}

	if ( ret <= 0 ) return ret;
   
	buf_out->buf_ptr += ret;
	if (buf_out->buf_ptr == buf_out->buf_end) {
		buf_out->buf_end = buf_out->buf_ptr = 0;
	}

	return ret;
}
Ejemplo n.º 3
0
static int
tlso_bio_write( BIO *b, const char *buf, int len )
{
	struct tls_data		*p;
	int			ret;
	
	if ( buf == NULL || len <= 0 ) return 0;
	
	p = (struct tls_data *)b->ptr;

	if ( p == NULL || p->sbiod == NULL ) {
		return 0;
	}

	ret = LBER_SBIOD_WRITE_NEXT( p->sbiod, (char *)buf, len );

	BIO_clear_retry_flags( b );
	if ( ret < 0 ) {
		int err = sock_errno();
		if ( err == EAGAIN || err == EWOULDBLOCK ) {
			BIO_set_retry_write( b );
		}
	}

	return ret;
}
Ejemplo n.º 4
0
static ber_slen_t
sb_rdahead_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len )
{
	assert( sbiod != NULL );
	assert( sbiod->sbiod_next != NULL );

	return LBER_SBIOD_WRITE_NEXT( sbiod, buf, len );
}
Ejemplo n.º 5
0
Archivo: tls_g.c Proyecto: 1ack/Impala
static ssize_t
tlsg_send( gnutls_transport_ptr_t ptr, const void *buf, size_t len )
{
	struct tls_data		*p;
	
	if ( buf == NULL || len <= 0 ) return 0;
	
	p = (struct tls_data *)ptr;

	if ( p == NULL || p->sbiod == NULL ) {
		return 0;
	}

	return LBER_SBIOD_WRITE_NEXT( p->sbiod, (char *)buf, len );
}