27 RCSIDH(lib_bio_base_h,
"$Id: c1d95b6c1dd16a8310a98d6b7364d6675a6a3500 $")
29 #include <freeradius-devel/util/debug.h>
30 #include <freeradius-devel/util/dlist.h>
35 #define XDEBUG(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
39 # error _CONST can only be defined in the local header
125 if (!prev)
return NULL;
134 if (!
next)
return NULL;
151 if (size == 0)
return 0;
158 return bio->read(bio, packet_ctx,
buffer, size);
174 if (size == 0)
return 0;
181 return bio->write(bio, packet_ctx,
buffer, size);
189 #define fr_bio_destructor (NULL)
192 #define fr_bio_error(_x) (-(FR_BIO_ERROR_ ## _x))
static int const char char buffer[256]
fr_bio_write_t _CONST write
write to the underlying bio
int fr_bio_free(fr_bio_t *bio)
Free this bio, and everything it calls.
fr_bio_read_t _CONST read
read from the underlying bio
int(* fr_bio_accept_t)(fr_bio_t *bio, TALLOC_CTX *ctx, fr_bio_t **accepted)
Accept a new connection on a bio.
fr_dlist_t _CONST entry
in the linked list of multiple bios
static ssize_t fr_bio_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
Write raw data to a bio.
void fr_bio_cb_set(fr_bio_t *bio, fr_bio_cb_funcs_t const *cb))
ssize_t(* fr_bio_read_t)(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Do a raw read from a socket, or other data source.
fr_bio_callback_t connected
called when the BIO is ready to be used
static ssize_t fr_bio_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Read raw data from a bio.
int(* fr_bio_io_t)(fr_bio_t *bio)
@ FR_BIO_ERROR_BUFFER_FULL
the buffer is full
@ FR_BIO_ERROR_GENERIC
generic "failed" error - check fr_strerror()
@ FR_BIO_ERROR_IO
IO error - check errno.
@ FR_BIO_ERROR_OOM
out of memory
@ FR_BIO_ERROR_VERIFY
some packet verification error
@ FR_BIO_ERROR_IO_WOULD_BLOCK
IO would block.
@ FR_BIO_ERROR_BUFFER_TOO_SMALL
the output buffer is too small for the data
fr_bio_callback_t eof
called when the BIO is at EOF
ssize_t(* fr_bio_write_t)(fr_bio_t *bio, void *packet_ctx, const void *buffer, size_t size)
fr_bio_callback_t shutdown
called when the BIO is being shut down
fr_bio_io_t read_resume
"unblocked" is too similar to "blocked"
int fr_bio_shutdown_intermediate(fr_bio_t *bio)
Like fr_bio_shutdown(), but can be called by anyone in the chain.
static fr_bio_t * fr_bio_prev(fr_bio_t *bio)
fr_bio_callback_t failed
called when the BIO fails
static fr_bio_t * fr_bio_next(fr_bio_t *bio)
void * uctx
user ctx, caller can manually set it.
fr_bio_io_t write_blocked
returns 0 for "couldn't block", 1 for "did block".
void(* fr_bio_callback_t)(fr_bio_t *bio)
char const * fr_bio_strerror(ssize_t error)
int fr_bio_destructor(fr_bio_t *bio)
Free this bio.
int fr_bio_shutdown(fr_bio_t *bio)
Shut down a set of BIOs.
static void * fr_dlist_entry_to_item(size_t offset, fr_dlist_t const *entry)
Get the item from a fr_dlist_t.
Entry in a doubly linked list.