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: 3cc55b20d1cc1cb0811cf1e79c4cd3bbbbb13b11 $
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: 3cc55b20d1cc1cb0811cf1e79c4cd3bbbbb13b11 $")
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
59
61
63
64/*
65 * Callbacks used to register coord_pair handling in a coordinator.
66 */
68 bool single_thread, void *uctx);
69void fr_coord_pair_inst_destroy(UNUSED fr_coord_t *coord, fr_coord_cb_inst_t *inst, bool single_thread, UNUSED void *uctx);
70
72 void *parent, void *uctx);
74
76
77/** Set callback for handling worker -> coordinator pair list data
78 * @param _id Callback ID to use
79 */
80#define FR_COORD_PAIR_CALLBACK(_id) [_id] = { .callback = fr_coord_pair_data_recv, .inst_create = fr_coord_pair_inst_create, .inst_destroy = fr_coord_pair_inst_destroy }
81
82/** Set callback for handling coordinator -> worker pair list data
83 * @param _id Callback ID to use
84 */
85#define FR_COORD_WORKER_PAIR_CALLBACK(_id) [_id] = { .callback = fr_coord_worker_pair_data_recv }
86
87/** Set up ctx on pair list callbacks
88 * @param _in_cb Array of worker -> coordinator callbacks.
89 * @param _out_cb Array of coordinator -> worker callbacks.
90 * @param _reg Registered coordinator pair list callback data.
91 */
92#define FR_COORD_PAIR_CB_CTX_SET(_in_cb, _out_cb, _reg) \
93 do { \
94 _in_cb[fr_coord_pair_reg_cb_id(_reg)].uctx = _reg; \
95 _out_cb[fr_coord_pair_reg_cb_id(_reg)].uctx = _reg; \
96 } while (0)
#define RCSIDH(h, id)
Definition build.h:513
#define UNUSED
Definition build.h:336
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
A coordinator which receives messages from workers.
Definition coord.c:49
The worker end of worker <-> coordinator communication.
Definition coord.c:73
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_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, module_ctx_t *mctx, void *uctx)
Definition coord_pair.h:35
void fr_coord_pair_inst_destroy(UNUSED fr_coord_t *coord, fr_coord_cb_inst_t *inst, bool single_thread, UNUSED void *uctx)
Definition coord_pair.c:552
int fr_coord_to_worker_reply_broadcast(request_t *request)
Send a reply list from a coordinator to all workers.
Definition coord_pair.c:780
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:752
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:811
CONF_SECTION * cs
Module conf section.
Definition coord_pair.h:47
void fr_coord_worker_pair_data_recv(fr_coord_worker_t *cw, fr_dbuff_t *dbuff, fr_time_t now, module_ctx_t *mctx, void *uctx)
Callback run when a worker receives pair list data.
Definition coord_pair.c:713
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_t * fr_coord_pair_request_coord_pair(request_t *request)
Return the coord_pair associated with a coord_pair internal request.
Definition coord_pair.c:869
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
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)
Instance creation called during coordinator creation.
Definition coord_pair.c:839
fr_coord_worker_pair_cb_t callback
Function to call.
Definition coord_pair.h:39
int fr_coord_pair_coord_request_start(fr_coord_pair_t *coord_pair, fr_pair_list_t *list, fr_time_t now)
Start a coordinator request to run through a coord_pair process module.
Definition coord_pair.c:884
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
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
static _Thread_local int worker_id
Internal ID of the current worker thread.
Definition schedule.c:104
eap_aka_sim_process_conf_t * inst
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