The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
BIO abstractions for file descriptors. More...
#include <freeradius-devel/bio/fd_priv.h>
#include <freeradius-devel/bio/null.h>
#include "fd_errno.h"
Go to the source code of this file.
Macros | |
#define | ADDR_INIT |
#define | flag_blocked info.read_blocked |
#define | flag_blocked info.read_blocked |
#define | flag_blocked info.read_blocked |
#define | flag_blocked info.write_blocked |
#define | flag_blocked info.write_blocked |
#define | flag_blocked info.read_blocked |
#define | SOL_IP IPPROTO_IP |
Functions | |
fr_bio_t * | fr_bio_fd_alloc (TALLOC_CTX *ctx, fr_bio_cb_funcs_t *cb, fr_bio_fd_config_t const *cfg, size_t offset) |
Allocate a FD bio. More... | |
int | fr_bio_fd_close (fr_bio_t *bio) |
Close the FD, but leave the bio allocated and alive. More... | |
int | fr_bio_fd_connect (fr_bio_t *bio) |
Finalize a connect() More... | |
static int | fr_bio_fd_destructor (fr_bio_fd_t *my) |
fr_bio_fd_info_t const * | fr_bio_fd_info (fr_bio_t *bio) |
Returns a pointer to the bio-specific information. More... | |
int | fr_bio_fd_init_accept (fr_bio_fd_t *my) |
int | fr_bio_fd_init_common (fr_bio_fd_t *my) |
int | fr_bio_fd_init_connected (fr_bio_fd_t *my) |
static int | fr_bio_fd_init_file (fr_bio_fd_t *my) |
Files are a special case of connected sockets. More... | |
static ssize_t | fr_bio_fd_read_accept (fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size) |
Return an fd on read() More... | |
static ssize_t | fr_bio_fd_read_connected_datagram (fr_bio_t *bio, UNUSED void *packet_ctx, void *buffer, size_t size) |
Connected datagram read. More... | |
static ssize_t | fr_bio_fd_read_discard (fr_bio_t *bio, UNUSED void *packet_ctx, void *buffer, size_t size) |
Discard all reads from a UDP socket. More... | |
static ssize_t | fr_bio_fd_read_stream (fr_bio_t *bio, UNUSED void *packet_ctx, void *buffer, size_t size) |
Stream read. More... | |
static ssize_t | fr_bio_fd_recvfrom (fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size) |
Read from a UDP socket where we know our IP. More... | |
static ssize_t | fr_bio_fd_sendto (fr_bio_t *bio, void *packet_ctx, const void *buffer, size_t size) |
Write to a UDP socket where we know our IP. More... | |
int | fr_bio_fd_socket_name (fr_bio_fd_t *my) |
static ssize_t | fr_bio_fd_try_connect (fr_bio_fd_t *my) |
Try to connect(). More... | |
static ssize_t | fr_bio_fd_write (fr_bio_t *bio, UNUSED void *packet_ctx, const void *buffer, size_t size) |
Write to fd. More... | |
int | fr_bio_fd_write_only (fr_bio_t *bio) |
Mark up a bio as write-only. More... | |
int | fr_filename_to_sockaddr (struct sockaddr_un *sun, socklen_t *sunlen, char const *filename) |
BIO abstractions for file descriptors.
Definition in file fd.c.
#define ADDR_INIT |
#define flag_blocked info.read_blocked |
#define flag_blocked info.read_blocked |
#define flag_blocked info.read_blocked |
#define flag_blocked info.write_blocked |
#define flag_blocked info.write_blocked |
#define flag_blocked info.read_blocked |
fr_bio_t* fr_bio_fd_alloc | ( | TALLOC_CTX * | ctx, |
fr_bio_cb_funcs_t * | cb, | ||
fr_bio_fd_config_t const * | cfg, | ||
size_t | offset | ||
) |
Allocate a FD bio.
The caller is responsible for tracking the FD, and all associated management of it. The bio API is intended to be simple, and does not provide wrapper functions for various ioctls. The caller should instead do that work.
Once the FD is give to the bio, its lifetime is "owned" by the bio. Calling talloc_free(bio) will close the FD.
The caller can still manage the FD for being readable / writeable. However, the caller should not call this bio directly (unless it is the only one). Instead, the caller should read from / write to the previous bio which will then eventually call this one.
Before updating any event handler readable / writeable callbacks, the caller should check fr_bio_fd_at_eof(). If true, then the handlers should not be inserted. The previous bios should still be called to process any pending data, until they return EOF.
The main purpose of an FD bio is to wrap the FD in a bio container. That, and handling retries on read / write, along with returning EOF as an error instead of zero.
Note that the read / write functions can return partial data. It is the callers responsibility to ensure that any writes continue from where they left off (otherwise dat awill be missing). And any partial reads should go to a memory bio.
If a read returns EOF, then the FD remains open until talloc_free(bio) or fr_bio_fd_close() is called.
ctx | the talloc ctx |
cb | callbacks |
cfg | structure holding configuration information |
offset | only for unconnected datagram sockets, where fr_bio_fd_packet_ctx_t is stored |
Definition at line 1018 of file fd.c.
int fr_bio_fd_close | ( | fr_bio_t * | bio | ) |
int fr_bio_fd_connect | ( | fr_bio_t * | bio | ) |
|
static |
fr_bio_fd_info_t const* fr_bio_fd_info | ( | fr_bio_t * | bio | ) |
int fr_bio_fd_init_accept | ( | fr_bio_fd_t * | my | ) |
int fr_bio_fd_init_common | ( | fr_bio_fd_t * | my | ) |
int fr_bio_fd_init_connected | ( | fr_bio_fd_t * | my | ) |
|
static |
|
static |
Connected datagram read.
The difference between this and stream protocols is that for datagrams. a read of zero means "no packets", where a read of zero on a steam socket means "EOF".
Connected sockets do not update per-packet contexts.
Definition at line 148 of file fd.c.
int fr_bio_fd_socket_name | ( | fr_bio_fd_t * | my | ) |
|
static |
Try to connect().
If connect is blocking, we either succeed or error immediately. Otherwise, the caller has to select the socket for writeability, and then call fr_bio_fd_connect() as soon as the socket is writeable.
Definition at line 682 of file fd.c.
int fr_bio_fd_write_only | ( | fr_bio_t * | bio | ) |