The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
control.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: 19c5b4e784addbcd824fd837832fbb90ff190a4a $
20 *
21 * @file io/control.h
22 * @brief control-plane signaling
23 *
24 * @copyright 2016 Alan DeKok (aland@freeradius.org)
25 */
26RCSIDH(control_h, "$Id: 19c5b4e784addbcd824fd837832fbb90ff190a4a $")
27
28#include <freeradius-devel/io/atomic_queue.h>
29#include <freeradius-devel/io/ring_buffer.h>
30#include <freeradius-devel/util/time.h>
31#include <freeradius-devel/util/event.h>
32
33#include <sys/types.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/**
40 * A one-way control plane signal.
41 *
42 * Multiple-producer, single consumer.
43 */
45typedef void (*fr_control_callback_t)(void *ctx, void const *data, size_t data_size, fr_time_t now);
46
47/*
48 * A suggestion for max # of messages, and max message size.
49 */
50#define FR_CONTROL_MAX_MESSAGES (1024)
51#define FR_CONTROL_MAX_SIZE (64)
52
54
56
58
59int fr_control_message_send(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size) CC_HINT(nonnull);
60
61int fr_control_message_push(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size) CC_HINT(nonnull);
62ssize_t fr_control_message_pop(fr_atomic_queue_t *aq, uint32_t *p_id, void *data, size_t data_size) CC_HINT(nonnull);
63
64int fr_control_callback_add(fr_control_t **c, uint32_t id, void *ctx, fr_control_callback_t callback) CC_HINT(nonnull(1,4));
66
68
69void fr_control_wait(fr_control_t *c) CC_HINT(nonnull);
70
71#ifdef __cplusplus
72}
73#endif
Structure to hold the atomic queue.
#define RCSIDH(h, id)
Definition build.h:507
int fr_control_gc(fr_control_t *c, fr_ring_buffer_t *rb)
ssize_t fr_control_message_pop(fr_atomic_queue_t *aq, uint32_t *p_id, void *data, size_t data_size)
Pop control-plane message.
Definition control.c:403
int fr_control_open(fr_control_t *c)
Open the control-plane signalling path.
Definition control.c:176
int fr_control_message_send(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size)
Send a control-plane message.
Definition control.c:355
int fr_control_message_push(fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size)
Push a control-plane message.
Definition control.c:315
fr_control_t * fr_control_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_atomic_queue_t *aq, size_t num_callbacks))
Create a control-plane signaling path.
Definition control.c:152
int fr_control_same_thread(fr_control_t *c)
Definition control.c:520
int fr_control_callback_delete(fr_control_t *c, uint32_t id)
Delete a callback for an ID.
Definition control.c:502
void(* fr_control_callback_t)(void *ctx, void const *data, size_t data_size, fr_time_t now)
Definition control.h:45
void fr_control_wait(fr_control_t *c)
Wait for a plane control to become readable.
Definition control.c:542
int fr_control_callback_add(fr_control_t **c, uint32_t id, void *ctx, fr_control_callback_t callback))
Register a callback for an ID.
Definition control.c:443
static fr_atomic_queue_t ** aq
uint32_t num_callbacks
the size of the callback array
Definition control.c:87
The control structure.
Definition control.c:76
Stores all information relating to an event list.
Definition event.c:377
unsigned int uint32_t
long int ssize_t
"server local" time.
Definition time.h:69
static fr_event_list_t * el
static fr_slen_t data
Definition value.h:1340
int nonnull(2, 5))