The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
coord_pair.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 8362d4872ac0ccf1b6a70ac38c97372da1a7f164 $
20 *
21 * @file io/coord_pair.h
22 * @brief Sending pair lists to and from coordination threads
23 *
24 * @copyright 2026 Network RADIUS SAS (legal@networkradius.com)
25 */
26RCSIDH(coord_pair_h, "$Id: 8362d4872ac0ccf1b6a70ac38c97372da1a7f164 $")
27
28#include <freeradius-devel/io/coord.h>
29#include <freeradius-devel/server/request.h>
30#include <freeradius-devel/util/pair.h>
31
32typedef struct fr_coord_pair_reg_s fr_coord_pair_reg_t;
34
36
37typedef struct {
38 uint32_t packet_type; //!< Packet type value for this callback
39 fr_coord_worker_pair_cb_t callback; //!< Function to call
40 void *uctx; //!< Ctx to pass to callback
42
43typedef struct {
44 fr_coord_worker_pair_cb_reg_t *worker_cb; //!< Callbacks for coordinator -> worker pair messages.
45 fr_dict_attr_t const *root; //!< Root attribute for decoding pair list messages.
46 uint32_t cb_id; //!< Coordinator callback id used for pair list messages.
47 CONF_SECTION *cs; //!< Module conf section.
48 fr_time_delta_t max_request_time; //!< Maximum time for coordinator request processing.
49 ///< Defaults to main config max request time.
51
53
55
57
58/*
59 * Callbacks used to register coord_pair handling in a coordinator.
60 */
62 bool single_thread, void *uctx);
64 void *parent, void *uctx);
66
68
69/** Set callback for handling worker -> coordinator pair list data
70 * @param _id Callback ID to use
71 */
72#define FR_COORD_PAIR_CALLBACK(_id) [_id] = { .callback = fr_coord_pair_data_recv, .inst_create = fr_coord_pair_inst_create }
73
74/** Set callback for handling coordinator -> worker pair list data
75 * @param _id Callback ID to use
76 */
77#define FR_COORD_WORKER_PAIR_CALLBACK(_id) [_id] = { .callback = fr_coord_worker_pair_data_recv }
78
79/** Set up ctx on pair list callbacks
80 * @param _in_cb Array of worker -> coordinator callbacks.
81 * @param _out_cb Array of coordinator -> worker callbacks.
82 * @param _reg Registered coordinator pair list callback data.
83 */
84#define FR_COORD_PAIR_CB_CTX_SET(_in_cb, _out_cb, _reg) \
85 do { \
86 _in_cb[fr_coord_pair_reg_cb_id(_reg)].uctx = _reg; \
87 _out_cb[fr_coord_pair_reg_cb_id(_reg)].uctx = _reg; \
88 } while (0)
#define RCSIDH(h, id)
Definition build.h:489
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
A coordinator which receives messages from workers.
Definition coord.c:47
The worker end of worker <-> coordinator communication.
Definition coord.c:71
fr_coord_pair_reg_t * coord_pair_reg
Registration details for this coord pair.
Definition coord_pair.c:60
fr_coord_worker_pair_cb_reg_t * worker_cb
Callbacks for coordinator -> worker pair messages.
Definition coord_pair.h:44
uint32_t packet_type
Packet type value for this callback.
Definition coord_pair.h:38
fr_time_delta_t max_request_time
Maximum time for coordinator request processing.
Definition coord_pair.h:48
void fr_coord_worker_pair_data_recv(fr_coord_worker_t *cw, fr_dbuff_t *dbuff, fr_time_t now, void *uctx)
Callback run when a worker receives pair list data.
Definition coord_pair.c:685
fr_dict_attr_t const * root
Root attribute for decoding pair list messages.
Definition coord_pair.h:45
int fr_coord_to_worker_reply_send(request_t *request, uint32_t worker_id)
Send a reply list from a coordinator to a worker.
Definition coord_pair.c:724
int fr_worker_to_coord_pair_send(fr_coord_worker_t *cw, fr_coord_pair_reg_t *coord_pair_reg, fr_pair_list_t *list)
Send a pair list from a worker to a coordinator.
Definition coord_pair.c:755
CONF_SECTION * cs
Module conf section.
Definition coord_pair.h:47
uint32_t fr_coord_pair_reg_cb_id(fr_coord_pair_reg_t *coord_pair_reg)
Return the coordinator callback ID associated with a coord_pair_reg_t.
Definition coord_pair.c:220
fr_coord_pair_reg_t * fr_coord_pair_register(TALLOC_CTX *ctx, fr_coord_pair_reg_ctx_t *reg_ctx)
Register a set of callbacks for pair list based coordinator messages.
Definition coord_pair.c:113
void(* fr_coord_worker_pair_cb_t)(fr_coord_worker_t *cw, fr_coord_pair_reg_t *coord_pair_reg, fr_pair_list_t const *list, fr_time_t now, void *uctx)
Definition coord_pair.h:35
fr_coord_cb_inst_t * fr_coord_pair_inst_create(TALLOC_CTX *ctx, fr_coord_t *coord, fr_event_list_t *el, bool single_thread, void *uctx)
Plugin creation called during coordinator creation.
Definition coord_pair.c:783
fr_coord_worker_pair_cb_t callback
Function to call.
Definition coord_pair.h:39
void * uctx
Ctx to pass to callback.
Definition coord_pair.h:40
struct fr_coord_pair_reg_s fr_coord_pair_reg_t
Definition coord_pair.h:32
uint32_t cb_id
Coordinator callback id used for pair list messages.
Definition coord_pair.h:46
void fr_coord_pair_data_recv(fr_coord_t *coord, uint32_t worker_id, fr_dbuff_t *dbuff, fr_time_t now, void *parent, void *uctx)
Stores all information relating to an event list.
Definition event.c:377
unsigned int uint32_t
static _Thread_local int worker_id
Internal ID of the current worker thread.
Definition schedule.c:103
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
"server local" time.
Definition time.h:69
static fr_event_list_t * el
static fr_slen_t parent
Definition pair.h:858