25 RCSIDH(connection_h,
"$Id: 6b671eabf4f042e0d23377fd0dbf8c9b12d52646 $")
31 #include <freeradius-devel/util/event.h>
32 #include <freeradius-devel/util/table.h>
33 #include <freeradius-devel/util/talloc.h>
36 # error _CONST can only be defined in the local header
38 #ifndef _CONNECTION_PRIVATE
270 char const *log_prefix,
void const *uctx);
fr_connection_shutdown_t shutdown
uint64_t _CONST id
Unique identifier for the connection.
uint64_t _CONST timed_out
How many times has this connection timed out when connecting.
fr_connection_state_t(* fr_connection_shutdown_t)(fr_event_list_t *el, void *h, void *uctx)
Start the process of gracefully shutting down the connection.
void fr_connection_signals_pause(fr_connection_t *conn)
Pause processing of deferred signals.
@ FR_CONNECTION_STATE_CLOSED
Connection has been closed.
@ FR_CONNECTION_STATE_HALTED
The connection is in a halted stat.
@ FR_CONNECTION_STATE_CONNECTING
Waiting for connection to establish.
@ FR_CONNECTION_STATE_FAILED
Connection has failed.
@ FR_CONNECTION_STATE_TIMEOUT
Timeout during FR_CONNECTION_STATE_CONNECTING.
@ FR_CONNECTION_STATE_INIT
Init state, sets up connection.
@ FR_CONNECTION_STATE_SHUTDOWN
Connection is shutting down.
@ FR_CONNECTION_STATE_MAX
@ FR_CONNECTION_STATE_CONNECTED
File descriptor is open (ready for writing).
int fr_connection_del_watch_pre(fr_connection_t *conn, fr_connection_state_t state, fr_connection_watch_t watch)
Remove a watch function from a pre list.
void fr_connection_watch_enable(fr_connection_watch_entry_t *entry)
Enable a watcher.
void(* fr_connection_watch_t)(fr_connection_t *conn, fr_connection_state_t prev, fr_connection_state_t state, void *uctx)
Receive a notification when a connection enters a particular state.
fr_time_delta_t reconnection_delay
How long to wait after failures.
uint64_t fr_connection_get_num_timed_out(fr_connection_t const *conn)
Return the number of times this connection has timed out whilst connecting.
void(* fr_connection_close_t)(fr_event_list_t *el, void *h, void *uctx)
Notification that the connection has errored and must be closed.
fr_connection_watch_entry_t * fr_connection_add_watch_post(fr_connection_t *conn, fr_connection_state_t state, fr_connection_watch_t watch, bool oneshot, void const *uctx)
Add a callback to be executed after a state function has been called.
void fr_connection_signal_connected(fr_connection_t *conn)
Asynchronously signal that the connection is open.
fr_connection_state_t _CONST state
Current connection state.
void fr_connection_signal_halt(fr_connection_t *conn)
Shuts down a connection ungracefully.
fr_connection_init_t init
void fr_connection_signals_resume(fr_connection_t *conn)
Resume processing of deferred signals.
fr_connection_state_t(* fr_connection_init_t)(void **h_out, fr_connection_t *conn, void *uctx)
Callback for the initialise state.
fr_connection_state_t(* fr_connection_failed_t)(void *h, fr_connection_state_t state, void *uctx)
Notification that a connection attempt has failed.
void fr_connection_signal_init(fr_connection_t *conn)
Asynchronously signal a halted connection to start.
size_t fr_connection_states_len
fr_connection_state_t(* fr_connection_open_t)(fr_event_list_t *el, void *h, void *uctx)
Notification that the connection is now open.
fr_connection_failed_t failed
fr_connection_watch_entry_t * fr_connection_add_watch_pre(fr_connection_t *conn, fr_connection_state_t state, fr_connection_watch_t watch, bool oneshot, void const *uctx)
Add a callback to be executed before a state function has been called.
void fr_connection_watch_enable_set_uctx(fr_connection_watch_entry_t *entry, void const *uctx)
Enable a watcher and replace the uctx.
fr_connection_close_t close
fr_connection_open_t open
void fr_connection_signal_shutdown(fr_connection_t *conn)
Shuts down a connection gracefully.
void *_CONST h
Connection handle.
uint64_t fr_connection_get_num_reconnected(fr_connection_t const *conn)
Return the number of times we've attempted to establish or re-establish this connection.
bool _CONST triggers
do we run the triggers?
fr_event_list_t *_CONST el
Event list for timers and I/O events.
int fr_connection_del_watch_post(fr_connection_t *conn, fr_connection_state_t state, fr_connection_watch_t watch)
Remove a watch function from a post list.
fr_time_delta_t connection_timeout
How long to wait for the connection to open or for shutdown to close the connection.
char const *_CONST name
Prefix to add to log messages.
bool fr_connection_watch_is_enabled(fr_connection_watch_entry_t *entry)
Return the state of a watch entry.
int fr_connection_signal_on_fd(fr_connection_t *conn, int fd)
Setup the connection to change states to connected or failed based on I/O events.
@ FR_CONNECTION_EXPIRED
Connection is being reconnected because it's at the end of its life.
@ FR_CONNECTION_FAILED
Connection is being reconnected because it failed.
fr_connection_t * fr_connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, fr_connection_funcs_t const *funcs, fr_connection_conf_t const *conf, char const *log_prefix, void const *uctx)
Allocate a new connection.
uint64_t _CONST reconnected
How many times we've attempted to establish or re-establish this connection.
fr_connection_state_t _CONST prev
The previous state the connection was in.
void fr_connection_watch_disable(fr_connection_watch_entry_t *entry)
Disable a watcher.
fr_table_num_ordered_t const fr_connection_states[]
void fr_connection_watch_set_uctx(fr_connection_watch_entry_t *entry, void const *uctx)
Change the uctx of an entry.
void fr_connection_signal_reconnect(fr_connection_t *conn, fr_connection_reason_t reason)
Asynchronously signal the connection should be reconnected.
Holds a complete set of functions for a connection.
Public fields for the connection.
Stores all information relating to an event list.
void * uctx
User data to pass to the function.
An entry in a watch function list.
An element in an arbitrarily ordered array of name to num mappings.
A time delta, a difference in time measured in nanoseconds.
static fr_event_list_t * el