The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Provides interface between libunbound and the FreeRADIUS event loop. More...
#include <freeradius-devel/server/log.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/syserror.h>
#include "io.h"
#include <unbound-event.h>
Go to the source code of this file.
Data Structures | |
struct | unbound_io_event_t |
Wrapper around event handle for our event loop. More... | |
Macros | |
#define | LOG_PREFIX "unbound" |
Typedefs | |
typedef void(* | unbound_cb_t) (int, short flags, void *uctx) |
Definition for libunbound's event callback. More... | |
Functions | |
static int | _event_base_free (unbound_io_event_base_t *ev_b) |
static int | _unbound_io_event_activate (struct ub_event *ub_ev, struct timeval *tv) |
Activate FD events and set a timer for a timeout. More... | |
static int | _unbound_io_event_deactivate (struct ub_event *ub_ev) |
static void | _unbound_io_event_fd_set (struct ub_event *ub_ev, int fd) |
Change the file descriptor associated with an event. More... | |
static void | _unbound_io_event_flags_add (struct ub_event *ub_ev, short flags) |
Alter the enabled flags associated with the event. More... | |
static void | _unbound_io_event_flags_del (struct ub_event *ub_ev, short flags) |
Alter the enabled flags associated with the event. More... | |
static void | _unbound_io_event_free (struct ub_event *ub_ev) |
Free an event, and, by the magic of talloc, any timers or fd events. More... | |
static struct ub_event * | _unbound_io_event_new (struct ub_event_base *base, int fd, short flags, void(*cb)(int, short, void *), void *uctx) |
Returns a new libunbound event handle. More... | |
static void | _unbound_io_service_errored (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, int fd_errno, void *uctx) |
Unbound FD errored. More... | |
static void | _unbound_io_service_readable (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx) |
Unbound FD became readable. More... | |
static void | _unbound_io_service_timer_expired (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Timeout fired. More... | |
static void | _unbound_io_service_writable (fr_event_list_t *el, int fd, UNUSED int flags, void *uctx) |
Unbound FD became writable. More... | |
static int | _unbound_io_timer_deactivate (struct ub_event *ub_ev) |
Deactivate a timeout. More... | |
static int | _unbound_io_timer_modify (struct ub_event *ub_ev, UNUSED struct ub_event_base *ev_b, void(*cb)(int, short, void *), void *uctx, struct timeval *tv) |
Modify an existing timeout. More... | |
int | unbound_io_init (TALLOC_CTX *ctx, unbound_io_event_base_t **ev_b_out, fr_event_list_t *el) |
Alloc a new event base, and unbound ctx initialised from that event base. More... | |
Provides interface between libunbound and the FreeRADIUS event loop.
Definition in file io.c.
struct unbound_io_event_t |
Wrapper around event handle for our event loop.
This stores libunbound specific information for an event in our event loop.
Lifetime should be bound to the event base.
Data Fields | ||
---|---|---|
bool | active | Whether this event is considered active. |
struct ub_event | base |
Unbound event base, which we populate with callback functions for adding events for FDs setting timers etc... MUST BE LISTED FIRST. |
unbound_cb_t | cb | The callback we need to call when a specified event happens. |
unbound_io_event_base_t * | ev_b | Event base this handle was created for. |
short | events | The events this event handle should receive when activated. |
int | fd | File descriptor this event handle relates to. |
fr_event_timer_t const * | timer |
Stores the pointer to the enabled timer for this event handled. libunbound uses a single handle for managing related FD events and timers, which is weird, but ok... |
void * | uctx |
This is the argument libunbound wants passed to the callback when it's called. It usually contains libunbound's internal connection handled. We don't have any visibility, it just remains an opaque blob to us. |
typedef void(* unbound_cb_t) (int, short flags, void *uctx) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Unbound FD errored.
libunbound doesn't request errors, so tell it a timeout occurred
Because we don't have the separation between the IO event loop and the event loop processing results, we call ub_process immediately after calling the IO callback.
Definition at line 221 of file io.c.
|
static |
Unbound FD became readable.
Because we don't have the separation between the IO event loop and the event loop processing results, we call ub_process immediately after calling the IO callback.
Definition at line 168 of file io.c.
|
static |
Timeout fired.
Unbound uses these timeouts as part of its mechanism to measure rtt from candidate DNS servers, working out which is the fastest to use for any given query. The timeout happening causes the timeout against the server to be increased for any subsequent queries sent to it.
Definition at line 153 of file io.c.
|
static |
|
static |
|
static |
int unbound_io_init | ( | TALLOC_CTX * | ctx, |
unbound_io_event_base_t ** | ev_b_out, | ||
fr_event_list_t * | el | ||
) |
Alloc a new event base, and unbound ctx initialised from that event base.
The ub_ctx is configured to use the el specified.
When the thread ctx is freed, unbound_io_free should be called to gracefully free the ub_ctx, and then the event base structure it depends on.
[in] | ctx | Talloc ctx to allocate even base in. |
[out] | ev_b_out | Event base. Free with talloc_free. |
[in] | el | To use to run the unbound event loop. |
Definition at line 482 of file io.c.