The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Binary IO abstractions for memory buffers. More...
Go to the source code of this file.
Typedefs | |
typedef fr_bio_verify_action_t(* | fr_bio_verify_t) (fr_bio_t *bio, void *verify_ctx, void *packet_ctx, const void *buffer, size_t *size) |
Verifies the packet. More... | |
Enumerations | |
enum | fr_bio_verify_action_t { FR_BIO_VERIFY_OK = 0 , FR_BIO_VERIFY_DISCARD , FR_BIO_VERIFY_WANT_MORE , FR_BIO_VERIFY_ERROR_CLOSE } |
Status returned by the verification callback. More... | |
Functions | |
fr_bio_t * | fr_bio_mem_alloc (TALLOC_CTX *ctx, size_t read_size, size_t write_size, fr_bio_t *next) |
Allocate a memory buffer bio. More... | |
void | fr_bio_mem_read_discard (fr_bio_t *bio, size_t size) |
Discard data from the read buffer. More... | |
uint8_t const * | fr_bio_mem_read_peek (fr_bio_t *bio, size_t *size) |
Peek at the data in the read buffer. More... | |
int | fr_bio_mem_set_verify (fr_bio_t *bio, fr_bio_verify_t verify, void *verify_ctx, bool datagram) |
Set the verification function for memory bios. More... | |
fr_bio_t * | fr_bio_mem_sink_alloc (TALLOC_CTX *ctx, size_t buffer_size) |
Allocate a memory buffer which sinks data from a bio system into the callers application. More... | |
fr_bio_t * | fr_bio_mem_source_alloc (TALLOC_CTX *ctx, size_t buffer_size, fr_bio_t *next) |
Allocate a memory buffer which sources data from the callers application into the bio system. More... | |
int | fr_bio_mem_write_resume (fr_bio_t *bio) |
See if we can resume writes to the memory bio. More... | |
Binary IO abstractions for memory buffers.
Allow reads and writes from memory buffers
Definition in file mem.h.
typedef fr_bio_verify_action_t(* fr_bio_verify_t) (fr_bio_t *bio, void *verify_ctx, void *packet_ctx, const void *buffer, size_t *size) |
Verifies the packet.
If the packet is a dup, then this function can return DISCARD, or update the packet_ctx to say "dup", and then return OK.
bio | the bio to read | |
verify_ctx | data specific for verifying | |
packet_ctx | as passed in to fr_bio_read() | |
buffer | pointer to the raw data | |
[in,out] | size | in: size of data in the buffer. out: size of the packet to return, or data to discard. |
fr_bio_t* fr_bio_mem_alloc | ( | TALLOC_CTX * | ctx, |
size_t | read_size, | ||
size_t | write_size, | ||
fr_bio_t * | next | ||
) |
Allocate a memory buffer bio.
The "read buffer" will cache reads from the next bio in the chain. If the next bio returns more data than the caller asked for, the extra data is cached in the read buffer.
The "write buffer" will buffer writes to the next bio in the chain. If the caller writes more data than the next bio can process, the extra data is cached in the write buffer.
When the bio is closed (or freed) any pending data in the buffers is lost. The same happens if the next bio returns a fatal error.
At some point during a read, the next bio may return EOF. When that happens, the caller should not rely on the next FD being readable or writable. Instead, it should keep reading from the memory bio until it returns EOF. See fr_bio_fd_eof() for details.
ctx | the talloc ctx |
read_size | size of the read buffer. Must be 1024..1^20 |
write_size | size of the write buffer. Can be zero. If non-zero, must be 1024..1^20 |
next | the next bio which will perform the underlying reads and writes.
|
Definition at line 727 of file mem.c.
int fr_bio_mem_set_verify | ( | fr_bio_t * | bio, |
fr_bio_verify_t | verify, | ||
void * | verify_ctx, | ||
bool | datagram | ||
) |
Set the verification function for memory bios.
It is possible to add a verification function. It is not currently possible to remove one.
bio | the binary IO handler |
verify | the verification function |
datagram | whether or not this bio is a datagram one. |
Definition at line 880 of file mem.c.
Allocate a memory buffer which sinks data from a bio system into the callers application.
The caller reads data from this bio, but never writes to it. Upstream BIOs will source the data.
Definition at line 845 of file mem.c.
int fr_bio_mem_write_resume | ( | fr_bio_t * | bio | ) |
See if we can resume writes to the memory bio.
Note that there is no equivalent fr_bio_mem_write_blocked(), as that function wouldn't do anything. Perhaps it could swap the write function to fr_bio_mem_write_buffer(), but the fr_bio_mem_write_next() function should automatically do that when the write to the next bio only writes part of the data, or if it returns fr_bio_error(IO_WOULD_BLOCK)
Definition at line 926 of file mem.c.