26#include <freeradius-devel/io/application.h>
27#include <freeradius-devel/io/listen.h>
28#include <freeradius-devel/io/pair.h>
29#include <freeradius-devel/server/connection.h>
30#include <freeradius-devel/unlang/function.h>
31#include <freeradius-devel/unlang/load_balance_priv.h>
32#include <freeradius-devel/unlang/subrequest.h>
33#include <freeradius-devel/util/heap.h>
34#include <freeradius-devel/util/rb_expire.h>
202#define DUP_INTERVAL fr_time_delta_from_sec(1)
225 UNUSED int flags,
void *uctx);
350 if (map_list_num_elements(&
inst->status_check_map) > 0) {
353 while ((map = map_list_next(&
inst->status_check_map, map))) {
444 DEBUG(
"%s - Reached maximum_retransmit_duration (%pVs > %pVs), failing status checks",
450 DEBUG(
"%s - Reached maximum_retransmit_count (%u > %u), failing status checks",
518 ERROR(
"%s - Failed reading response from socket: there is no server listening on outgoing connection %s",
523 ERROR(
"%s - Failed reading response from socket: %s",
541 ERROR(
"%s - Received response to expired status check packet",
551 ERROR(
"%s - Received response with incorrect or expired Token. Expected %u, got %u",
557 ERROR(
"%s - Received response with incorrect or expired ID. Expected %u, got %u",
589 DEBUG(
"%s - Received %u / %u replies for status check, on connection - %s",
591 DEBUG(
"%s - Next status check packet will be in %pVs",
639 DEBUG(
"%s - Sending %s ID %d over connection %s",
658 ERROR(
"%s - Failed sending %s ID %d length %zu over connection %s: %s",
666 if ((
size_t)slen < u->packet_len) {
668 ERROR(
"%s - Failed sending %s ID %d length %zu over connection %s: writing is blocked",
682 DEBUG(
"%s - %s request. Expecting response within %pVs",
717 if (!h->
tconn)
return 1;
742 if (!h->
tconn)
return 1;
778 h->tls_starting =
true;
780 h->tls_starting =
false;
799 if (h->p_self) *h->p_self = NULL;
819 h->conn_request = NULL;
841 h->tls_started =
true;
871 static uint64_t number = 0;
924 talloc_set_destructor(h->p_self, _bio_handle_self_free);
932static void bio_tls_connected(
fr_bio_t *bio)
941 if (tls_conn->tls_session->alpn_id == FR_RADIUS_ALPN_RADIUS_1_1) {
995static void bio_tls_failed(
fr_bio_t *bio)
1000 if (tls_conn->failed == TLS_CONNECTION_FAIL_SYSCALL) {
1013 if (h->tls_starting)
return;
1037 fr_tls_connection_t *tls_conn;
1039 if (conn_request_alloc(h) < 0)
return -1;
1048 bio_handle_detach(h);
1050 h->conn_request = NULL;
1056 .connected = bio_tls_connected,
1057 .failed = bio_tls_failed,
1063 h->ctx.fd_info->
name);
1093 if (h->conn_request) {
1111 bio_handle_detach(h);
1115 h->conn_request = NULL;
1191 size_t in_buffer = *size;
1196 if (in_buffer < 20) {
1219#define REQUIRE_MA(_h) (((_h)->ctx.inst->require_message_authenticator == FR_RADIUS_REQUIRE_MA_YES) || *(_h)->ctx.inst->received_message_authenticator)
1221#define REQUIRE_MA(_h) (!(_h)->bio.tls && (((_h)->ctx.inst->require_message_authenticator == FR_RADIUS_REQUIRE_MA_YES) || *(_h)->ctx.inst->received_message_authenticator))
1236 ERROR(
"We are configured with 'require_message_authenticator = true'");
1238 ERROR(
"We previously received a packet from this client which included a Message-Authenticator attribute");
1293 h->
bio.
fd->uctx = h;
1324 ERROR(
"%s - Failed opening socket to home server %pV:%u - source port %u is already in use",
1349 ERROR(
"%s - Failed opening socket to home server %pV:%u - source port %u is already in use",
1382 if (h->
ctx.ssl_ctx) {
1383 if (conn_tls_alloc(h) < 0) {
1423 h->
bio.main = h->
bio.mem;
1424 h->
bio.mem->uctx = h;
1430 .write_blocked = (h->ctx.fd_config.socket_type == SOCK_STREAM) ? bio_write_blocked : NULL,
1445 if (to_save) *to_save = conn;
1468 if (rcode < 0)
goto fail;
1525 if (to_save) *to_save = conn;
1592 DEBUG4(
"Freeing handle %p", handle);
1632 char const *log_prefix,
void *uctx)
1647 PERROR(
"%s - Failed allocating state handler for new connection", ctx->
inst->
name);
1650 ctx->
trunk = tconn->trunk;
1749 switch (notify_on) {
1819 if (ret != 0)
return ret;
1825 if (ret != 0)
return ret;
1863 .request_code = u->
code,
1864 .request_authenticator = request_authenticator,
1865 .tmp_ctx = talloc(ctx,
uint8_t),
1866 .end =
data + data_len,
1868 .require_message_authenticator =
REQUIRE_MA(h),
1875 return decode_ctx.
reason;
1881 RDEBUG(
"Received %s ID %d length %zu reply packet on connection %s",
1898 !*(
inst->received_message_authenticator) &&
1901 RINFO(
"Packet contained a valid Message-Authenticator. Setting \"require_message_authenticator = yes\"");
1902 *(
inst->received_message_authenticator) =
true;
1905 *response_code = code;
1955 .add_proxy_state = u->
proxied,
1982 if (packet_len < 0) {
1983 RPERROR(
"Failed encoding packet");
1991 fr_assert((
size_t) packet_len <= u->packet_len);
2020 RPERROR(
"Failed signing packet");
2094 ERROR(
"Failed inserting revive timeout for connection");
2128 DEBUG(
"%s - Reached maximum_retransmit_duration (%pVs > %pVs), failing status checks",
2135 DEBUG(
"%s - Reached maximum_retransmit_count (%u > %u), failing status checks",
2290 ERROR(
"Failed inserting zombie timeout for connection");
2303 RDEBUG(
"Request is queued and waiting for a connection - suppressing retransmission");
2312 RDEBUG(
"Request has not been sent - suppressing retransmission");
2319 RDEBUG(
"Using stream sockets - suppressing retransmission");
2327 RDEBUG(
"IO is blocked - suppressing retransmission");
2363 RDEBUG(
"Packet was cancelled by the connection handler - ignoring retry");
2373 tconn = treq->tconn;
2376 switch (retry->
state) {
2380 switch (treq->state) {
2387 RDEBUG(
"Packet is still in the backlog queue to be sent - suppressing retransmission");
2391 RDEBUG(
"Packet is still in the pending queue to be sent - suppressing retransmission");
2395 RDEBUG(
"Packet was partially written, as IO is blocked - suppressing retransmission");
2417 REDEBUG(
"Reached maximum_retransmit_duration (%pVs > %pVs), failing request",
2422 REDEBUG(
"Reached maximum_retransmit_count (%u > %u), failing request",
2445 if (!was_sent)
return;
2477 h = talloc_get_type_abort(tconn->conn->h,
bio_handle_t);
2483 DEBUG(
"%s - Moved %" PRIu64
" pending request(s) off of blocked connection %s",
2562 RDEBUG(
"Sending %s ID %d length %zu over connection %s",
2582 RDEBUG(
"Retransmitting %s ID %d length %zu over connection %s",
2604 if (slen ==
fr_bio_error(IO_WOULD_BLOCK))
goto requeue;
2612 ERROR(
"%s - Failed sending data over connection %s: %s",
2622 ERROR(
"%s - Failed sending data over connection %s: %s",
2642 ERROR(
"%s - Failed sending %s ID %d length %zu over connection %s: Destination network is down or unreachable",
2649 RWARN(
"%s - Failed sending data over connection %s: sent zero bytes",
2688 action =
"Retransmitted";
2694 action =
"Retransmitted";
2696 action = u->
proxied ?
"Proxied" :
"Originated";
2734 RDEBUG(
"%s request. Expecting response within %pVs", action,
2742 RDEBUG(
"%s request. Relying on NAS to perform more retransmissions", action);
2766 bool error_601 =
false;
2782 if (error == 601) error_601 =
true;
2809 if (attr[1] != 7)
continue;
2819 if ((attr[3] != 0) ||
2833 if (attr[6] != u->
code) {
2846 if (error_601 && response_length && (response_length > h->
buflen)) {
2847 if (response_length < 4096) response_length = 4096;
2848 if (response_length > 65535) response_length = 65535;
2856 h->
buflen = response_length;
2909 DEBUG(
"Received %u / %u replies for status check, on connection - %s",
2922 DEBUG(
"Received enough replies to status check, marking connection as active - %s", h->
ctx.
fd_info->
name);
2972 ERROR(
"%s - Failed reading response from socket: %s",
2986 WARN(
"%s - Ignoring reply with %s that arrived too late",
3056 if (!h->
radius_1_1)
RWDEBUG(
"Protocol-Error response is missing Original-Packet-Code");
3064 vp->vp_uint32 = FR_ERROR_CAUSE_VALUE_PROXY_PROCESSING_ERROR;
3115 treq->request->reply->code = code;
3191 ERROR(
"%s - Failed reading response from socket: %s",
3214 WARN(
"%s - Ignoring reply with %s that arrived too late",
3430 RDEBUG(
"Duplicate packet received %pVs after the last write - suppressing retransmission",
3449 if (!u->
treq)
return 0;
3487 REDEBUG(
"Failed allocating handler for request");
3512 REDEBUG(
"Unable to queue packet - connections at maximum capacity");
3520 REDEBUG(
"All destinations are down - cannot send packet");
3524 REDEBUG(
"Unable to queue packet");
3535 switch (
inst->mode) {
3538 REDEBUG(
"Internal sanity check failed - connection trunking cannot be used for replication");
3633 bool delay_start =
false;
3644 if (
inst->tls_conf) {
3645 thread->
ctx.ssl_ctx = fr_tls_ctx_alloc(
inst->tls_conf,
true);
3646 if (!thread->
ctx.ssl_ctx) {
3647 PERROR(
"%s - failed allocating TLS context",
inst->name);
3653 switch (
inst->mode) {
3656 inst->home_server_lifetime);
3664 uint16_t range =
inst->fd_config.src_port_end -
inst->fd_config.src_port_start + 1;
3685 &
inst->trunk_conf,
inst->name, thread, delay_start,
inst->trigger_args);
3694 &
inst->trunk_conf,
inst->name, thread,
false,
inst->trigger_args);
3716 if (!thread->
bio.fd) {
3717 PERROR(
"%s - failed opening socket",
inst->name);
3721 thread->
bio.fd->uctx = thread;
3739 if (thread->
ctx.ssl_ctx) SSL_CTX_free(thread->
ctx.ssl_ctx);
3775 RPERROR(
"Invalid destination IP address family in %pV", ipaddr);
3783 REDEBUG(
"Cannot replicate packet code %u, it is not a RADIUS packet code",
request->packet->code);
3791 RWDEBUG(
"Replication of packets other then Accounting-Request will likely not do what you want.");
3799 .secret_length =
secret->vb_length,
3804 .common = &radius_ctx,
3809 .code =
request->packet->code,
3810 .id = thread->
bio.id++ & 0xff,
3811 .add_proxy_state =
false,
3819 if (packet_len < 0) {
3820 RPERROR(
"Failed encoding replicated packet");
3828 RPERROR(
"Failed signing replicated packet");
3838 addr.
socket.inet.dst_ipaddr = ipaddr->vb_ip;
3839 addr.
socket.inet.dst_port = port->vb_uint16;
3841 RDEBUG(
"Replicating packet to %pV:%u", ipaddr, port->vb_uint16);
3847 if (packet_len < 0) {
3848 RPERROR(
"Failed replicating packet to %pV:%u", ipaddr, port->vb_uint16);
3871 if (rcode != 0)
return rcode;
3886 dst->vb_uint32 =
request->reply->code;
3934 REDEBUG(
"Cannot proxy packet code %u, it is not a RADIUS packet code",
request->packet->code);
3942 RDEBUG(
"Invalid destination IP address family in %pV", ipaddr);
3948 .fd_config = (fr_bio_fd_config_t) {
3949 .dst_ipaddr = ipaddr->vb_ip,
3950 .dst_port = port->vb_uint16,
3964 .module_name =
inst->name,
3969 .ssl_ctx = thread->ctx.ssl_ctx,
3972 .num_ports = thread->num_ports,
3979 home->ctx.fd_config = thread->ctx.fd_config;
3981 home->ctx.fd_config.dst_ipaddr = ipaddr->vb_ip;
3982 home->ctx.fd_config.dst_port = port->vb_uint16;
3986 .secret_length =
secret->vb_length,
3987 .proxy_state =
inst->common_ctx.proxy_state,
3994 &
inst->trunk_conf,
inst->name, home,
false,
inst->trigger_args);
3995 if (!home->ctx.trunk) {
4012 if ((home->ctx.radius_ctx.secret_length !=
secret->vb_length) ||
4013 (strcmp(home->ctx.radius_ctx.secret,
secret->vb_strvalue) != 0)) {
4014 RWDEBUG(
"The new secret is not the same as the old secret: Ignoring the new one");
4027 if (old == home)
break;
4032 if (old->
ctx.
trunk->req_alloc)
break;
4051 REDEBUG(
"Failed enqueuing packet");
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
@ UNLANG_ACTION_YIELD
Temporarily pause execution until an event occurs.
static int const char char buffer[256]
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.
static ssize_t fr_bio_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Read raw data from a bio.
void * uctx
user ctx, caller can manually set it.
static int packet_ctx
the tests pass only the address of packet_ctx
static uint8_t request[4]
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
#define CC_NO_UBSAN(_sanitize)
#define CMP_PREFER_LARGER(_a, _b)
Evaluates to -1 for a > b, and +1 for a < b.
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
fr_cmp_ret_t
Result of an ordering comparison.
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
#define fr_assert_fail(_msg,...)
Calls panic_action ifndef NDEBUG, else logs error.
@ FR_RADIUS_CODE_ACCESS_CHALLENGE
RFC2865 - Access-Challenge.
@ FR_RADIUS_CODE_ACCESS_REQUEST
RFC2865 - Access-Request.
@ FR_RADIUS_CODE_MAX
Maximum possible protocol code.
@ FR_RADIUS_CODE_DISCONNECT_ACK
RFC3575/RFC5176 - Disconnect-Ack (positive)
@ FR_RADIUS_CODE_STATUS_SERVER
RFC2865/RFC5997 - Status Server (request)
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
@ FR_RADIUS_CODE_ACCOUNTING_RESPONSE
RFC2866 - Accounting-Response.
@ FR_RADIUS_CODE_COA_NAK
RFC3575/RFC5176 - CoA-Nak (not willing to perform)
@ FR_RADIUS_CODE_COA_ACK
RFC3575/RFC5176 - CoA-Ack (positive)
@ FR_RADIUS_CODE_DISCONNECT_NAK
RFC3575/RFC5176 - Disconnect-Nak (not willing to perform)
@ FR_RADIUS_CODE_PROTOCOL_ERROR
RFC7930 - Protocol-Error (generic NAK)
@ FR_RADIUS_CODE_ACCOUNTING_REQUEST
RFC2866 - Accounting-Request.
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
static fr_dict_attr_t const * attr_packet_type
int main(int argc, char **argv)
bool fr_dict_compatible(fr_dict_t const *dict1, fr_dict_t const *dict2)
See if two dictionaries have the same end parent.
static void * fr_dlist_head(fr_dlist_head_t const *list_head)
Return the HEAD item of a list or NULL if the list is empty.
static void * fr_dlist_remove(fr_dlist_head_t *list_head, void *ptr)
Remove an item from the list.
#define fr_event_fd_insert(...)
void(* fr_event_fd_cb_t)(fr_event_list_t *el, int fd, int flags, void *uctx)
Called when an IO event occurs on a file descriptor.
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
int fr_bio_fd_connect_full(fr_bio_t *bio, fr_event_list_t *el, fr_bio_callback_t connected_cb, fr_bio_callback_t error_cb, fr_time_delta_t *timeout, fr_bio_callback_t timeout_cb)
Finalize a connect()
fr_bio_t * fr_bio_fd_alloc(TALLOC_CTX *ctx, fr_bio_fd_config_t const *cfg, size_t offset)
Allocate a FD bio.
fr_bio_fd_info_t const * fr_bio_fd_info(fr_bio_t *bio)
Returns a pointer to the bio-specific information.
int fr_bio_fd_write_only(fr_bio_t *bio)
Mark up a bio as write-only.
fr_socket_t socket
as connected socket
char const * name
printable name of this BIO
uint16_t src_port
our port
fr_bio_fd_type_t type
type of the socket
fr_bio_fd_state_t state
connecting, open, closed, etc.
uint16_t src_port_start
limit source port ranges for client BIOs
int connect_errno
from connect() or other APIs
fr_ipaddr_t dst_ipaddr
their IP address
@ FR_BIO_FD_CONNECTED
connected client sockets (UDP or TCP)
@ FR_BIO_FD_UNCONNECTED
unconnected UDP / datagram, but also allowed
uint16_t src_port_end
limit source port ranges for client BIOs
int socket_type
SOCK_STREAM or SOCK_DGRAM.
uint16_t dst_port
their port
@ FR_BIO_FD_STATE_CONNECTING
@ FR_BIO_FD_STATE_OPEN
error states must be before this
fr_socket_t socket
socket information, including FD.
bool write_blocked
did we block on write?
fr_ipaddr_t src_ipaddr
our IP address
Configuration for sockets.
Run-time status of the socket.
#define unlang_function_push(_request, _func, _repeat, _signal, _sigmask, _top_frame, _uctx)
Push a generic function onto the unlang stack.
fr_cmp_ret_t fr_ipaddr_cmp(fr_ipaddr_t const *a, fr_ipaddr_t const *b)
Compare two ip addresses.
void unlang_interpret_set(request_t *request, unlang_interpret_t *intp)
Set a specific interpreter for a request.
void unlang_interpret_mark_runnable(request_t *request)
Mark a request as resumable.
unlang_interpret_t * unlang_interpret_get_thread_default(void)
Get the default interpreter for this thread.
unlang_t const * unlang_interpret_instruction(request_t *request)
Get the current instruction.
void unlang_interpret_signal(request_t *request, fr_signal_t action)
Send a signal (usually stop) to a request.
int unlang_interpret_force_result(unlang_t const *instruction, unlang_result_t *p_result, fr_timer_list_t *tl, fr_time_delta_t expire)
Set (or clear) a forced result.
fr_event_list_t * unlang_interpret_event_list(request_t *request)
Get the event list for the current interpreter.
el_self ties the lifetime of the event list to the interpreter
void fr_bio_cb_set(fr_bio_t *bio, fr_bio_cb_funcs_t const *cb)
void fr_bio_tls_close_send(fr_bio_tls_t *my)
Send a TLS close_notify alert to the peer.
fr_tls_connection_t * fr_bio_tls_conn(fr_bio_tls_t *my)
The TLS connection, so the caller can set conn->name
int fr_bio_tls_connect(fr_bio_tls_t *my)
Take the connection through every state which comes before application data.
fr_bio_tls_t * fr_bio_tls_alloc(request_t *request, fr_bio_t *next, SSL_CTX *ssl_ctx, bool client, bool client_cert)
Allocate a TLS bio.
HIDDEN fr_dict_attr_t const * attr_eap_message
void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a list of protocol fr_pair_ts.
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
#define RPEDEBUG(fmt,...)
#define HEXDUMP3(_data, _len, _fmt,...)
#define RHEXDUMP3(_data, _len, _fmt,...)
int map_to_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, UNUSED void *uctx)
Convert a map to a fr_pair_t.
int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t func, void *ctx)
Convert map_t to fr_pair_t (s) and add them to a request_t.
int fr_event_fd_delete(fr_event_list_t *el, int fd, fr_event_filter_t filter)
Remove a file descriptor from the event loop.
Stores all information relating to an event list.
#define fr_log(_log, _lvl, _file, _line, _fmt,...)
@ L_DBG_LVL_3
3rd highest priority debug messages (-xxx | -Xx).
@ L_DBG_LVL_2
2nd highest priority debug messages (-xx | -X).
fr_packet_t * fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new fr_packet_t.
Minimal data structure to use the new code.
int unlang_load_balance_persist(request_t *request)
Persist the current load-balance selection.
main_config_t const * main_config
Main server configuration.
uint32_t max_workers
for the scheduler
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.
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.
fr_bio_verify_action_t
Status returned by the verification callback.
@ FR_BIO_VERIFY_ERROR_CLOSE
fatal error, the bio should be closed.
@ FR_BIO_VERIFY_DISCARD
the packet should be discarded
@ FR_BIO_VERIFY_OK
packet is OK
@ FR_BIO_VERIFY_WANT_MORE
not enough data for one packet
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
bool fr_radius_ok(uint8_t const *packet, size_t *packet_len_p, uint32_t max_attributes, bool require_message_authenticator, bool radius_1_1, decode_fail_t *reason)
module_instance_t const * mi
Instance of the module being instantiated.
void * thread
Thread specific instance data.
void * rctx
Resume ctx that a module previously set.
fr_event_list_t * el
Event list to register any IO handlers and timers against.
void * thread
Thread instance data.
module_instance_t const * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for thread_instantiation calls.
bool radius_1_1
RADIUS/1.1 has been negotiated for this connection.
static int mod_enqueue(bio_request_t **p_u, fr_retry_config_t const **p_retry_config, rlm_radius_t const *inst, trunk_t *trunk, request_t *request)
fr_bio_fd_config_t fd_config
for threads or sockets
uint32_t token
Last Token assigned to this packet. Only for RADIUS/1.1.
static void do_retry(rlm_radius_t const *inst, bio_request_t *u, request_t *request, fr_retry_t const *retry)
fr_timer_t * ev
timer for retransmissions
static void status_check_timeout(UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx)
We timed out, without getting a status check reply.
static void request_replicate_mux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
static void conn_init_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx)
Connection errored.
size_t buflen
Receive buffer length.
static void request_demux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
radius_track_t * tt
RADIUS ID tracking structure.
static void conn_discard(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
Read and discard data.
uint8_t id
Last ID assigned to this packet.
static void request_replicate_demux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
static void do_signal(rlm_radius_t const *inst, bio_request_t *u, request_t *request, fr_signal_t action)
trunk_connection_event_t notify_on
The events which the trunk last asked for.
bool dynamic
is this a dynamic home server.
bool status_checking
whether we're doing status checks
static void bio_connected(fr_bio_t *bio)
uint32_t num_replies
number of reply packets, sent is in retry.count
static const trunk_io_funcs_t io_funcs
static void conn_close(UNUSED fr_event_list_t *el, void *handle, void *uctx)
Shutdown/close a file descriptor.
uint32_t priority
copied from request->async->priority
trunk_connection_t * tconn
The trunk connection.
static rlm_rcode_t radius_code_to_rcode[FR_RADIUS_CODE_MAX]
Turn a reply code into a module rcode;.
static bool bio_at_eof(bio_handle_t const *h)
Is the connection at EOF?
static void conn_error(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx)
Connection errored.
char const * module_name
the module that opened the connection
fr_bio_fd_info_t const * fd_info
status of the FD.
connection_t * connections[]
for tracking outbound connections
static void bio_eof(fr_bio_t *bio)
The BIO chain is at EOF, and has no more data for us.
uint8_t * buffer
Receive buffer.
static void mod_retry(module_ctx_t const *mctx, request_t *request, fr_retry_t const *retry)
Handle module retries.
static fr_radius_decode_fail_t decode(TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, bio_handle_t *h, request_t *request, bio_request_t *u, uint8_t const request_authenticator[static RADIUS_AUTH_VECTOR_LENGTH], uint8_t *data, size_t data_len)
Decode response packet data, extracting relevant information and validating the packet.
static int encode(bio_handle_t *h, request_t *request, bio_request_t *u, uint8_t id)
fr_time_t last_written
when the last whole packet was last written.
static void request_conn_release(connection_t *conn, void *preq_to_reset, UNUSED void *uctx)
Clear out anything associated with the handle from the request.
bio_handle_ctx_t ctx
common struct for home servers and BIO handles
static fr_bio_verify_action_t rlm_radius_verify(UNUSED fr_bio_t *bio, void *verify_ctx, UNUSED void *packet_ctx, const void *data, size_t *size)
static void mod_write(request_t *request, trunk_request_t *treq, bio_handle_t *h)
fr_pair_list_t extra
VPs for debugging, like Proxy-State.
bool proxied
is this request being proxied
uint32_t timeouts
Requests which timed out without a reply since the last reply.
bool write_blocked
A stream write blocked, and has not yet resumed.
bool eof
The BIO chain is at EOF, see bio_eof().
@ LIMIT_PORTS_DYNAMIC
Limited source ports for dynamic home servers.
@ LIMIT_PORTS_NONE
Source port not restricted.
@ LIMIT_PORTS_STATIC
Limited source ports for static home servers.
static fr_cmp_ret_t request_prioritise(void const *one, void const *two)
static void bio_tracking_entry_log(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, radius_track_entry_t *te)
Log additional information about a tracking entry.
static xlat_action_t xlat_radius_replicate(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
fr_time_t first_unanswered
When the current run of unanswered requests started.
radius_track_entry_t * rr
ID tracking, resend count, etc.
fr_time_t last_reply
When we last received a reply.
size_t packet_len
Length of the packet.
static int _bio_handle_free(bio_handle_t *h)
Free a connection handle, closing associated resources.
static void conn_writable_flush(fr_event_list_t *el, int fd, int flags, void *uctx)
The fd is writable, and the connection is blocked on write.
size_t partial
partially sent data
fr_event_list_t * el
Event list.
static int bio_write_blocked(fr_bio_t *bio)
Pause the connection when a stream BIO is blocked on write.
static void request_cancel(UNUSED connection_t *conn, void *preq_to_reset, trunk_cancel_reason_t reason, UNUSED void *uctx)
Remove the request from any tracking structures.
static void home_server_free(void *data)
static void protocol_error_reply(bio_request_t *u, bio_handle_t *h)
Deal with Protocol-Error replies, and possible negotiation.
static void status_check_reset(bio_handle_t *h, bio_request_t *u)
Reset a status_check packet, ready to reuse.
static const trunk_io_funcs_t io_replicate_funcs
static void request_fail(request_t *request, NDEBUG_UNUSED void *preq, void *rctx, NDEBUG_UNUSED trunk_request_state_t state, UNUSED void *uctx)
Write out a canned failure.
fr_time_t recv_time
copied from request->async->recv_time
fr_retry_t retry
retransmission timers
fr_timer_t * zombie_ev
Zombie timeout. Only used when status_check = no.
static void conn_init_writable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
Send initial negotiation.
static xlat_action_t xlat_radius_client(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
struct bio_handle_s bio_handle_t
Track the handle, which is tightly correlated with the FD.
rlm_rcode_t rcode
from the transport
static void thread_conn_notify(trunk_connection_t *tconn, connection_t *conn, fr_event_list_t *el, trunk_connection_event_t notify_on, void *uctx)
struct bio_handle_s::@227 bio
static void status_check_alloc(bio_handle_t *h)
static void status_check_reply(trunk_connection_t *tconn, bio_request_t *u, fr_time_t now)
Deal with replies replies to status checks and possible negotiation.
trunk_t * trunk
trunk handler
fr_timer_list_t * tl
Timers for this connection.
bio_handle_ctx_t ctx
for copying to bio_handle_t
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
Instantiate thread data for the submodule.
static void bio_error(fr_bio_t *bio)
static bool check_for_zombie(request_t *request, trunk_connection_t *tconn, fr_time_t now, fr_time_t last_sent)
Decide whether a request timeout marks the connection as zombie.
unlang_t const * instruction
Instruction which triggered the start of the zombie period.
static void mod_signal(module_ctx_t const *mctx, request_t *request, fr_signal_t action)
static void conn_init_next(UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
Perform the next step of init and negotiation.
request_t * status_request
static int _bio_request_free(bio_request_t *u)
Free a bio_request_t.
static unlang_action_t mod_resume(unlang_result_t *p_result, module_ctx_t const *mctx, UNUSED request_t *request)
Resume execution of the request, returning the rcode set during trunk execution.
static connection_t * thread_conn_alloc(trunk_connection_t *tconn, fr_event_list_t *el, connection_conf_t const *conf, char const *log_prefix, void *uctx)
static int conn_write_only(bio_handle_t *h)
Replication is write-only, so the socket never reads.
bio_request_t * status_u
for sending status check packets
static void xlat_sendto_retry(xlat_ctx_t const *xctx, request_t *request, fr_retry_t const *retry)
static void bio_request_reset(bio_request_t *u)
Clear out any connection specific resources from a udp request.
struct bio_thread_t::@226 bio
static void status_check_enqueue(trunk_connection_t *tconn, bio_handle_t *h, bool init)
Queue a status check packet on an open connection, and wait for the reply.
static void mux_requeue_if_blocked(trunk_connection_t *tconn)
Requeue packets if the connection is blocked on write.
fr_time_t last_sent
last time we wrote a request.
uint32_t max_packet_size
Our max packet size. may be different from the parent.
static xlat_action_t xlat_sendto_resume(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
static void status_check_next(UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
Send the next status check, after the previous status check got a reply.
rlm_radius_t const * inst
our instance
static connection_state_t conn_init(void **h_out, connection_t *conn, void *uctx)
Initialise a new outbound connection.
static void conn_init_readable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
Read the connection during the init and negotiation stage.
connection_t ** connections
bio_handle_ctx_t ctx
common struct for home servers and BIO handles
fr_rb_expire_node_t expire
static void revive_timeout(UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
Revive a connection after "revive_interval".
uint8_t last_id
Used when replicating to ensure IDs are distributed evenly.
uint8_t * packet
Packet we write to the network.
static void conn_init_timeout(UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx)
Status check timer when opening the connection for the first time.
static connection_state_t conn_failed(void *handle, connection_state_t state, UNUSED void *uctx)
Connection failed.
bio_limit_ports_t limit_source_ports
What type of port limit is in use.
fr_radius_ctx_t radius_ctx
for signing packets
static void mod_dup(request_t *request, bio_request_t *u)
static int mod_thread_detach(module_thread_inst_ctx_t const *mctx)
Free thread data for the submodule.
static void request_mux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
static fr_cmp_ret_t home_server_cmp(void const *one, void const *two)
Dynamic home server code.
static void request_complete(request_t *request, NDEBUG_UNUSED void *preq, void *rctx, UNUSED void *uctx)
Response has already been written to the rctx at this point.
bool status_check
is this packet a status check?
static xlat_arg_parser_t const xlat_radius_send_args[]
static void xlat_sendto_signal(xlat_ctx_t const *xctx, request_t *request, fr_signal_t action)
static void zombie_timeout(UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx)
Mark a connection dead after "zombie_interval".
static int bio_write_resume(fr_bio_t *bio)
Resume the connection when a stream BIO can write again.
Track the handle, which is tightly correlated with the FD.
Connect request_t to local tracking structure.
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
static uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
#define RADIUS_HEADER_LENGTH
#define RADIUS_AUTH_VECTOR_LENGTH
int fr_pair_delete_by_da_nested(fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete matching pairs from the specified list, and prune any empty branches.
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
fr_pair_t * fr_pair_find_by_da_nested(fr_pair_list_t const *list, fr_dict_attr_t const *da)
Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
int fr_pair_delete_by_da(fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete matching pairs from the specified list.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
static fr_internal_encode_ctx_t encode_ctx
static fr_dict_attr_t const * attr_state
static fr_dict_attr_t const * attr_error_cause
ssize_t fr_radius_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t *packet, size_t packet_len, fr_radius_decode_ctx_t *decode_ctx)
int fr_radius_sign(uint8_t *packet, uint8_t const *vector, uint8_t const *secret, size_t secret_len)
Sign a previously encoded packet.
ssize_t fr_radius_encode(fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_radius_encode_ctx_t *packet_ctx)
char const * fr_radius_packet_name[FR_RADIUS_CODE_MAX]
static fr_dict_attr_t const * attr_proxy_state
static fr_dict_attr_t const * attr_message_authenticator
bool secure_transport
for TLS
#define RADIUS_AUTH_VECTOR_OFFSET
fr_radius_decode_fail_t
Failure reasons.
@ FR_RADIUS_FAIL_MA_MISSING
#define FR_RADIUS_PACKET_CODE_VALID(_x)
fr_radius_ctx_t const * common
@ FR_RADIUS_REQUIRE_MA_YES
Require Message-Authenticator.
@ FR_RADIUS_REQUIRE_MA_AUTO
Only require Message-Authenticator if we've previously received a packet from this client with Messag...
fr_radius_decode_fail_t reason
reason for decode failure
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
static fr_dict_t const * dict_radius
static fr_dict_attr_t const * attr_extended_attribute_1
uint32_t fr_rand(void)
Return a 32-bit random number.
Smaller fast random number generator.
int fr_rb_find(void **found, fr_rb_tree_t const *tree, void const *data)
Find an element in the tree, returning the data, not the node.
int fr_rb_delete(fr_rb_tree_t *tree, void const *data)
Remove node and free data (if a free function was specified)
bool fr_rb_expire_insert(fr_rb_expire_t *expire, void *data, fr_time_t now)
Attempt to find current data in the tree, if it does not exist insert it.
void fr_rb_expire_update(fr_rb_expire_t *expire, void *data, fr_time_t now)
#define fr_rb_expire_inline_talloc_init(_expire, _type, _field, _data_cmp, _data_free, _lifetime)
dlist for expiring old entries
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_REJECT
Immediately reject the request.
@ RLM_MODULE_UPDATED
OK (pairs modified).
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
#define RETURN_UNLANG_RCODE(_rcode)
#define request_local_alloc_internal(_ctx, _args)
Allocate a new internal request outside of the request pool.
#define request_local_alloc_external(_ctx, _args)
Allocate a new external request outside of the request pool.
Optional arguments for initialising requests.
static int radius_fixups(rlm_radius_t const *inst, request_t *request)
Do any RADIUS-layer fixups for proxying.
static fr_dict_attr_t const * attr_nas_identifier
static fr_dict_attr_t const * attr_original_packet_code
static fr_dict_attr_t const * attr_event_timestamp
static fr_dict_attr_t const * attr_response_length
fr_radius_require_ma_t require_message_authenticator
Require Message-Authenticator in responses.
fr_time_delta_t revive_interval
bool track_load_balance
do we track load-balance state
fr_retry_config_t retry[FR_RADIUS_CODE_MAX]
uint32_t status_check
code of status-check type
rlm_radius_mode_t mode
proxy, client, etc.
@ RLM_RADIUS_MODE_XLAT_PROXY
radius.sendto.ipaddr(), but we do look for a reply.
@ RLM_RADIUS_MODE_INVALID
@ RLM_RADIUS_MODE_PROXY
we proxy to one home server
@ RLM_RADIUS_MODE_REPLICATE
to a particular destination
@ RLM_RADIUS_MODE_UNCONNECTED_REPLICATE
radius.sendto.ipaddr(), but we don't look for a reply
@ RLM_RADIUS_MODE_CLIENT
we are a client to one home server
uint32_t max_packet_size
Maximum packet size.
uint32_t max_attributes
Maximum number of attributes to decode in response.
uint32_t response_timeouts
Requests in a row which have to time out before the connection is zombie.
fr_time_delta_t zombie_period
static conf_parser_t retry_config[]
static void fr_rtt_update(fr_rtt_t *r, fr_time_delta_t t)
Update the smoothed round trip time and the variation with a new sample.
int fr_schedule_worker_id(void)
Return the worker id for the current thread.
void connection_signal_reconnect(connection_t *conn, connection_reason_t reason)
Asynchronously signal the connection should be reconnected.
int connection_signal_on_fd(connection_t *conn, int fd)
Setup the connection to change states to connected or failed based on I/O events.
connection_t * connection_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, connection_funcs_t const *funcs, connection_conf_t const *conf, char const *log_prefix, void const *uctx)
Allocate a new connection.
void connection_signal_connected(connection_t *conn)
Asynchronously signal that the connection is open.
@ CONNECTION_FAILED
Connection is being reconnected because it failed.
@ CONNECTION_STATE_FAILED
Connection has failed.
@ CONNECTION_STATE_CONNECTED
File descriptor is open (ready for writing).
@ CONNECTION_STATE_INIT
Init state, sets up connection.
@ CONNECTION_STATE_CONNECTING
Waiting for connection to establish.
Holds a complete set of functions for a connection.
void * data
Module's instance data.
#define pair_append_request(_attr, _da)
Allocate and append a fr_pair_t to the request list.
#define FR_SIGNAL_ALLOW(_signals)
Signal mask which blocks every signal except the ones in _signals.
fr_signal_t
Signals that can be generated/processed by request signal handlers.
@ FR_SIGNAL_DUP
A duplicate request was received.
@ FR_SIGNAL_NONE
No signals.
@ FR_SIGNAL_CANCEL
Request has been cancelled.
init
Enter the EAP-IDENTITY state.
eap_aka_sim_process_conf_t * inst
Stores an attribute, a value and various bits of other data.
int unlang_subrequest_child_push_and_detach(request_t *request)
Add a child request to the runnable queue.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...)
Call talloc vasprintf, setting the type on the new chunk correctly.
#define talloc_get_type_abort_const
static int talloc_const_free(void const *ptr)
Free const'd memory.
#define talloc_strdup(_ctx, _str)
#define fr_time_gteq(_a, _b)
#define fr_time_delta_lt(_a, _b)
#define fr_time_delta_wrap(_time)
#define fr_time_wrap(_time)
#define fr_time_delta_ispos(_a)
#define fr_time_eq(_a, _b)
static fr_cmp_ret_t fr_time_cmp(fr_time_t a, fr_time_t b)
Compare two fr_time_t values.
#define fr_time_add(_a, _b)
Add a time/time delta together.
#define fr_time_gt(_a, _b)
#define fr_time_sub(_a, _b)
Subtract one time from another.
static fr_unix_time_t fr_time_to_unix_time(fr_time_t when)
Convert an fr_time_t (internal time) to our version of unix time (wallclock time)
#define fr_time_delta_gt(_a, _b)
A time delta, a difference in time measured in nanoseconds.
fr_timer_list_t * fr_timer_list_lst_alloc(TALLOC_CTX *ctx, fr_timer_list_t *parent)
Allocate a new lst based timer list.
#define FR_TIMER_DELETE(_ev_p)
#define FR_TIMER_DELETE_RETURN(_ev_p)
#define FR_TIMER_DISARM(_ev)
static bool fr_timer_armed(fr_timer_t *ev)
void radius_track_state_log(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, radius_track_t *tt, radius_track_log_extra_t extra)
Print out the state of every tracking entry.
int radius_track_entry_update(radius_track_entry_t *te, uint8_t const *vector)
Update a tracking entry with the authentication vector.
radius_track_t * radius_track_alloc(TALLOC_CTX *ctx, bool radius_1_1)
Create an radius_track_t.
radius_track_entry_t * radius_track_entry_find(radius_track_t *tt, uint8_t packet_id, uint8_t const *vector)
Find a tracking entry from a request authenticator.
#define radius_track_entry_release(_te)
void * uctx
Result/resumption context.
unsigned int num_requests
number of requests in the allocation
#define radius_track_entry_reserve(_te_out, _ctx, _tt, _request, _code, _uctx)
request_t * request
as always...
Track one request to a response.
void trunk_connection_callback_readable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
Standard I/O read function.
void trunk_connection_callback_writable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
Standard I/O write function.
void trunk_request_signal_partial(trunk_request_t *treq)
Signal a partial write.
void trunk_request_signal_fail(trunk_request_t *treq)
Signal that a trunk request failed.
trunk_request_t * trunk_request_alloc(trunk_t *trunk, request_t *request)
(Pre-)Allocate a new trunk request
uint64_t trunk_connection_requests_requeue(trunk_connection_t *tconn, int states, uint64_t max, bool fail_bound)
Move requests off of a connection and requeue elsewhere.
trunk_enqueue_t trunk_request_enqueue_on_conn(trunk_request_t **treq_out, trunk_connection_t *tconn, request_t *request, void *preq, void *rctx, bool ignore_limits)
Enqueue additional requests on a specific connection.
trunk_enqueue_t trunk_request_enqueue(trunk_request_t **treq_out, trunk_t *trunk, request_t *request, void *preq, void *rctx)
Enqueue a request that needs data written to the trunk.
trunk_enqueue_t trunk_request_requeue(trunk_request_t *treq)
Re-enqueue a request on the same connection.
int trunk_connection_pop_request(trunk_request_t **treq_out, trunk_connection_t *tconn)
Pop a request off a connection's pending queue.
void trunk_request_signal_cancel(trunk_request_t *treq)
Cancel a trunk request.
trunk_t * trunk_alloc(TALLOC_CTX *ctx, fr_event_list_t *el, trunk_io_funcs_t const *funcs, trunk_conf_t const *conf, char const *log_prefix, void const *uctx, bool delay_start, fr_pair_list_t *trigger_args)
Allocate a new collection of connections.
void trunk_request_free(trunk_request_t **treq_to_free)
If the trunk request is freed then update the target requests.
void trunk_connection_signal_active(trunk_connection_t *tconn)
Signal a trunk connection is no longer full.
void trunk_connection_signal_inactive(trunk_connection_t *tconn)
Signal a trunk connection cannot accept more requests.
void trunk_request_signal_sent(trunk_request_t *treq)
Signal that the request was written to a connection successfully.
void trunk_request_signal_complete(trunk_request_t *treq)
Signal that a trunk request is complete.
void trunk_connection_signal_reconnect(trunk_connection_t *tconn, connection_reason_t reason)
Signal a trunk connection is no longer viable.
void trunk_request_state_log(fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, trunk_request_t const *treq)
bool trunk_connection_in_state(trunk_connection_t *tconn, int state)
Returns true if the trunk connection is in one of the specified states.
Associates request queues with a connection.
Main trunk management handle.
trunk_connection_event_t
What type of I/O events the trunk connection is currently interested in receiving.
@ TRUNK_CONN_EVENT_BOTH
Trunk should be notified if a connection is readable or writable.
@ TRUNK_CONN_EVENT_WRITE
Trunk should be notified if a connection is writable.
@ TRUNK_CONN_EVENT_NONE
Don't notify the trunk on connection state changes.
@ TRUNK_CONN_EVENT_READ
Trunk should be notified if a connection is readable.
#define TRUNK_REQUEST_STATE_ALL
All request states.
@ TRUNK_CONN_INACTIVE
Connection is inactive and can't accept any more requests.
trunk_connection_alloc_t connection_alloc
Allocate a new connection_t.
@ TRUNK_ENQUEUE_DST_UNAVAILABLE
Destination is down.
@ TRUNK_ENQUEUE_FAIL
General internal sanity check failure.
@ TRUNK_ENQUEUE_OK
Operation was successful.
@ TRUNK_ENQUEUE_NO_CAPACITY
At maximum number of connections, and no connection has capacity.
@ TRUNK_ENQUEUE_IN_BACKLOG
Request should be enqueued in backlog.
trunk_request_state_t
Used for sanity checks and to simplify freeing.
@ TRUNK_REQUEST_STATE_PARTIAL
Some of the request was written to the socket, more of it should be written later.
@ TRUNK_REQUEST_STATE_REAPABLE
Request has been written, needs to persist, but we are not currently waiting for any response.
@ TRUNK_REQUEST_STATE_UNASSIGNED
Transition state - Request currently not assigned to any connection.
@ TRUNK_REQUEST_STATE_INIT
Initial state.
@ TRUNK_REQUEST_STATE_CANCEL_SENT
We've informed the remote server that the request has been cancelled.
@ TRUNK_REQUEST_STATE_COMPLETE
The request is complete.
@ TRUNK_REQUEST_STATE_FAILED
The request failed.
@ TRUNK_REQUEST_STATE_CANCEL
A request on a particular socket was cancel.
@ TRUNK_REQUEST_STATE_CANCEL_PARTIAL
We partially wrote a cancellation request.
@ TRUNK_REQUEST_STATE_BACKLOG
In the backlog.
@ TRUNK_REQUEST_STATE_CANCEL_COMPLETE
Remote server has acknowledged our cancellation.
@ TRUNK_REQUEST_STATE_PENDING
In the queue of a connection and is pending writing.
@ TRUNK_REQUEST_STATE_SENT
Was written to a socket. Waiting for a response.
trunk_cancel_reason_t
Reasons for a request being cancelled.
@ TRUNK_CANCEL_REASON_REQUEUE
A previously sent request is being requeued.
I/O functions to pass to trunk_alloc.
static fr_event_list_t * el
xlat_action_t unlang_xlat_yield_to_retry(request_t *request, xlat_func_t resume, fr_unlang_xlat_retry_t retry, xlat_func_signal_t signal, fr_signal_t sigmask, void *rctx, fr_retry_config_t const *retry_cfg)
Yield a request back to the interpreter, with retries.
@ XLAT_ACTION_FAIL
An xlat function failed.
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
#define XLAT_ARGS(_list,...)
Populate local variables with value boxes from the input list.
unsigned int required
Argument must be present, and non-empty.
#define XLAT_ARG_PARSER_TERMINATOR
Definition for a single argument consumed by an xlat function.
A node in a graph of unlang_op_t (s) that we execute.
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
fr_retry_state_t fr_retry_next(fr_retry_t *r, fr_time_t now)
Initialize a retransmission counter.
void fr_retry_init(fr_retry_t *r, fr_time_t now, fr_retry_config_t const *config)
Initialize a retransmission counter.
fr_time_t start
when we started the retransmission
fr_time_delta_t rt
retransmit interval
uint32_t mrc
Maximum retransmission count.
fr_retry_config_t const * config
master configuration
fr_retry_state_t state
so callers can see what state it's in.
uint32_t count
number of sent packets
fr_time_delta_t mrd
Maximum retransmission duration.
fr_time_t updated
last update, really a cached "now".
@ FR_RETRY_MRC
reached maximum retransmission count
@ FR_RETRY_MRD
reached maximum retransmission duration
fr_time_t next
when the next timer should be set
int af
AF_INET, AF_INET6, or AF_UNIX.
int fd
File descriptor if this is a live socket.
char const * fr_strerror(void)
Get the last library error.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
static fr_sbuff_err_t char size_t fr_sbuff_t * in
#define fr_box_ipaddr(_val)
static fr_sbuff_err_t char ** out
#define fr_box_time_delta(_val)
void * rctx
Resume context.
module_ctx_t const * mctx
Synthesised module calling ctx.