|  | The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
    | 
Binary IO abstractions. More...
#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/dlist.h> Include dependency graph for base.h:
 Include dependency graph for base.h:Go to the source code of this file.
| Data Structures | |
| struct | fr_bio_cb_funcs_t | 
| struct | fr_bio_s | 
| Macros | |
| #define | _CONST const | 
| #define | fr_bio_error(_x) (-(FR_BIO_ERROR_ ## _x)) | 
| #define | XDEBUG(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__) | 
| Typedefs | |
| typedef int(* | fr_bio_accept_t) (fr_bio_t *bio, TALLOC_CTX *ctx, fr_bio_t **accepted) | 
| Accept a new connection on a bio. | |
| typedef void(* | fr_bio_callback_t) (fr_bio_t *bio) | 
| typedef int(* | fr_bio_io_t) (fr_bio_t *bio) | 
| typedef 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. | |
| typedef struct fr_bio_s | fr_bio_t | 
| typedef ssize_t(* | fr_bio_write_t) (fr_bio_t *bio, void *packet_ctx, const void *buffer, size_t size) | 
| Functions | |
| void | fr_bio_cb_set (fr_bio_t *bio, fr_bio_cb_funcs_t const *cb)) | 
| int | fr_bio_destructor (fr_bio_t *bio) | 
| Free this bio. | |
| static fr_bio_t * | fr_bio_head (fr_bio_t *bio) | 
| static fr_bio_t * | fr_bio_next (fr_bio_t *bio) | 
| static fr_bio_t * | fr_bio_prev (fr_bio_t *bio) | 
| 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_shutdown (fr_bio_t *bio) | 
| Shut down a set of BIOs. | |
| int | fr_bio_shutdown_intermediate (fr_bio_t *bio) | 
| Like fr_bio_shutdown(), but can be called by anyone in the chain. | |
| ssize_t | fr_bio_shutdown_read (fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size) | 
| ssize_t | fr_bio_shutdown_write (fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size) | 
| char const * | fr_bio_strerror (ssize_t error) | 
| 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. | |
Binary IO abstractions.
Create abstract binary input / output buffers.
Definition in file base.h.
| struct fr_bio_cb_funcs_t | 
 Collaboration diagram for fr_bio_cb_funcs_t:
 Collaboration diagram for fr_bio_cb_funcs_t:| Data Fields | ||
|---|---|---|
| fr_bio_callback_t | connected | called when the BIO is ready to be used | 
| fr_bio_callback_t | eof | called when the BIO is at EOF | 
| fr_bio_callback_t | failed | called when the BIO fails | 
| fr_bio_io_t | read_blocked | |
| fr_bio_io_t | read_resume | "unblocked" is too similar to "blocked" | 
| fr_bio_io_t | shutdown | called when the BIO is being shut down | 
| fr_bio_io_t | write_blocked | returns 0 for "couldn't block", 1 for "did block". | 
| fr_bio_io_t | write_resume | |
| struct fr_bio_s | 
 Collaboration diagram for fr_bio_s:
 Collaboration diagram for fr_bio_s:| Data Fields | ||
|---|---|---|
| fr_dlist_t _CONST | entry | in the linked list of multiple bios | 
| fr_bio_read_t _CONST | read | read from the underlying bio | 
| void * | uctx | user ctx, caller can manually set it. | 
| fr_bio_write_t _CONST | write | write to the underlying bio | 
Do a raw read from a socket, or other data source.
These functions should be careful about packet_ctx. This handling depends on a number of factors. Note that the packet_ctx may be NULL!
Stream sockets will generally ignore packet_ctx.
Datagram sockets generally write src/dst IP/port to the packet context. This same packet_ctx is then passed to bio->write(), which can use it to send the data to the correct destination.
| bio | the binary IO handler | 
| packet_ctx | where the function can store per-packet information, such as src/dst IP/port for datagram sockets | 
| buffer | where the function should store data it reads | 
| size | the maximum amount of data to read. | 
| enum fr_bio_error_type_t | 
| Enumerator | |
|---|---|
| FR_BIO_ERROR_NONE | |
| FR_BIO_ERROR_GENERIC | -1 == generic "failed" error - check fr_strerror() | 
| FR_BIO_ERROR_IO_WOULD_BLOCK | IO would block. | 
| 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_BUFFER_FULL | the buffer is full | 
| FR_BIO_ERROR_BUFFER_TOO_SMALL | the output buffer is too small for the data | 
| FR_BIO_ERROR_SHUTDOWN | the BIO has been shut down | 
| void fr_bio_cb_set | ( | fr_bio_t * | bio, | 
| fr_bio_cb_funcs_t const * | cb | ||
| ) | 
| int fr_bio_destructor | ( | fr_bio_t * | bio | ) | 
Free this bio.
We allow talloc_free() to be called on just about anything in the bio chain. But we ensure that the chain is always shut down in an orderly fashion.
Definition at line 35 of file base.c.
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inlinestatic | 
Read raw data from a bio.
| bio | the binary IO handler | 
| packet_ctx | packet-specific data associated with the buffer | 
| buffer | where to read the data | 
| size | amount of data to read. | 
Definition at line 161 of file base.h.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int fr_bio_shutdown | ( | fr_bio_t * | bio | ) | 
Shut down a set of BIOs.
We shut down the BIOs from the top to the bottom. This gives the TLS BIO an opportunity to call the SSL_shutdown() routine, which should then write to the FD BIO. Once that write is completed, the FD BIO can then close its socket.
Any shutdown is "stop read / write", but is not "free all resources". A shutdown can happen when one of the intermediary BIOs hits a fatal error. It can't free the BIO, but it has to mark the entire BIO chain as being unusable.
A destructor will first shutdown the BIOs, and then free all resources.
Definition at line 98 of file base.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int fr_bio_shutdown_intermediate | ( | fr_bio_t * | bio | ) | 
Like fr_bio_shutdown(), but can be called by anyone in the chain.
Definition at line 150 of file base.c.
 Here is the call graph for this function:
 Here is the call graph for this function:| ssize_t fr_bio_shutdown_write | ( | fr_bio_t * | bio, | 
| void * | packet_ctx, | ||
| void const * | buffer, | ||
| size_t | size | ||
| ) | 
| char const * fr_bio_strerror | ( | ssize_t | error | ) | 
| 
 | inlinestatic | 
Write raw data to a bio.
| bio | the binary IO handler | 
| packet_ctx | packet-specific data associated with the buffer | 
| buffer | the data to write. If NULL, will "flush" any pending data. | 
| size | amount of data to write. For flush, it should be SIZE_MAX | 
Definition at line 184 of file base.h.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function: 1.9.8
 1.9.8