Hello,
This is a new feature proposal for BIO_f_buffer.
The current implementation allows the user to write some data to the
buffer, and then flush it to the underlying BIO, using the BIO_flush
call.
A similar mechanism would be helpful for the receiving side: fill the
buffer with some data from the underlying BIO, and then the user may
read data from the buffer.
This patch introduces a new call, BIO_fill(b,n), which attempts to fill
buffer b with n bytes.
Return value: number of bytes read from the next BIO.

Cheers,

Yair



diff -ur C:\openssl_dist\crypto\bio\bf_buff.c
C:\openssl\crypto\bio\bf_buff.c
--- C:\openssl_dist\crypto\bio\bf_buff.c Wed Jun 11 21:43:50 2003
+++ C:\openssl\crypto\bio\bf_buff.c Tue Mar 22 11:33:37 2005
@@ -509,3 +509,35 @@
return(buffer_write(b,str,strlen(str)));
}
=20
+int BIO_fill(BIO *b, int pendingbytes)
+{
+ int i,num=3D0;
+ BIO_F_BUFFER_CTX *ctx;
+
+ if (b=3D=3DNULL || pendingbytes=3D=3D0) return(0);
+ ctx=3D(BIO_F_BUFFER_CTX *)b->ptr;
+
+ if (ctx->ibuf_off > (ctx->ibuf_size/2))
+ {
+ memcpy(ctx->ibuf, ctx->ibuf + ctx->ibuf_off, ctx->ibuf_len);
+ ctx->ibuf_off =3D 0;
+ }
+
+ if ((ctx =3D=3D NULL) || (b->next_bio =3D=3D NULL)) return(0);
+ while ((numibuf_size - ctx->ibuf_len -
ctx->ibuf_off)>0 )
+ {
+ BIO_clear_retry_flags(b);
+
+ i=3DBIO_read(b->next_bio, ctx->ibuf+ctx->ibuf_off+ctx->ibuf_len,
ctx->ibuf_size-ctx->ibuf_len-ctx->ibuf_off);
+ if (i <=3D 0)
+ {
+ BIO_copy_next_retry(b);
+ if (i < 0) return((num > 0)?num:i);
+ if (i =3D=3D 0) return(num);
+ }
+ num +=3D i;
+ ctx->ibuf_len +=3D i;
+ }
+ return num;
+}
+
diff -ur C:\openssl_dist\include\openssl\bio.h
C:\openssl\include\openssl\bio.h
--- C:\openssl_dist\include\openssl\bio.h Wed Mar 24 14:35:20 2004
+++ C:\openssl\include\openssl\bio.h Tue Mar 22 11:34:37 2005
@@ -486,6 +486,8 @@
size_t BIO_ctrl_get_write_guarantee(BIO *b);
size_t BIO_ctrl_get_read_request(BIO *b);
int BIO_ctrl_reset_read_request(BIO *b);
+int BIO_fill(BIO *b, int pendingbytes);
+
=20
/* These two aren't currently implemented */
/* int BIO_get_ex_num(BIO *bio); */


__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
Development Mailing List openssl-dev@openssl.org
Automated List Manager majordomo@openssl.org