The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
message.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: 7206e0084927a678f99326376394966cea8ac4fd $
20 *
21 * @file io/message.h
22 * @brief Inter-thread messaging
23 *
24 * @copyright 2016 Alan DeKok (aland@freeradius.org)
25 */
26RCSIDH(message_h, "$Id: 7206e0084927a678f99326376394966cea8ac4fd $")
27
28#include <freeradius-devel/util/time.h>
29#include <freeradius-devel/io/ring_buffer.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36
43
44typedef struct {
45 fr_message_status_t status; //!< free, used, done, etc.
46
47 fr_time_t when; //!< when this message was sent
48 fr_ring_buffer_t *rb; //!< pointer to the ring buffer
49 uint8_t *data; //!< pointer to the data in the ring buffer
50 size_t data_size; //!< size of the data in the ring buffer
51 size_t rb_size; //!< cache-aligned size in the ring buffer
53
54fr_message_set_t *fr_message_set_create(TALLOC_CTX *ctx, int num_messages, size_t message_size, size_t ring_buffer_size) CC_HINT(nonnull);
55
57fr_message_t *fr_message_alloc(fr_message_set_t *ms, fr_message_t *m, size_t actual_packet_size) CC_HINT(nonnull(1));
58fr_message_t *fr_message_alloc_reserve(fr_message_set_t *ms, fr_message_t *m, size_t actual_packet_size,
59 size_t leftover, size_t reserve_size) CC_HINT(nonnull);
60int fr_message_done(fr_message_t *m) CC_HINT(nonnull);
61
62fr_message_t *fr_message_localize(TALLOC_CTX *ctx, fr_message_t *m, size_t message_size) CC_HINT(nonnull);
63
66
67void fr_message_set_debug(fr_message_set_t *ms, FILE *fp) CC_HINT(nonnull);
68
69#ifdef __cplusplus
70}
71#endif
#define RCSIDH(h, id)
Definition build.h:484
unsigned char uint8_t
A Message set, composed of message headers and ring buffer data.
Definition message.c:95
fr_ring_buffer_t * rb
pointer to the ring buffer
Definition message.h:48
size_t rb_size
cache-aligned size in the ring buffer
Definition message.h:51
fr_message_t * fr_message_alloc(fr_message_set_t *ms, fr_message_t *m, size_t actual_packet_size))
Allocate packet data for a message.
Definition message.c:988
int fr_message_done(fr_message_t *m)
Mark a message as done.
Definition message.c:190
fr_message_t * fr_message_localize(TALLOC_CTX *ctx, fr_message_t *m, size_t message_size)
Localize a message by copying it to local storage.
Definition message.c:242
fr_time_t when
when this message was sent
Definition message.h:47
uint8_t * data
pointer to the data in the ring buffer
Definition message.h:49
int fr_message_set_messages_used(fr_message_set_t *ms)
Count the number of used messages.
Definition message.c:1212
void fr_message_set_debug(fr_message_set_t *ms, FILE *fp)
Print debug information about the message set.
Definition message.c:1262
size_t data_size
size of the data in the ring buffer
Definition message.h:50
void fr_message_set_gc(fr_message_set_t *ms)
Garbage collect the message set.
Definition message.c:1238
fr_message_status_t
Definition message.h:37
@ FR_MESSAGE_USED
Definition message.h:39
@ FR_MESSAGE_LOCALIZED
Definition message.h:40
@ FR_MESSAGE_DONE
Definition message.h:41
@ FR_MESSAGE_FREE
Definition message.h:38
fr_message_t * fr_message_reserve(fr_message_set_t *ms, size_t reserve_size)
Reserve a message.
Definition message.c:934
fr_message_t * fr_message_alloc_reserve(fr_message_set_t *ms, fr_message_t *m, size_t actual_packet_size, size_t leftover, size_t reserve_size)
Allocate packet data for a message, and reserve a new message.
Definition message.c:1077
fr_message_status_t status
free, used, done, etc.
Definition message.h:45
fr_message_set_t * fr_message_set_create(TALLOC_CTX *ctx, int num_messages, size_t message_size, size_t ring_buffer_size)
Create a message set.
Definition message.c:127
static size_t reserve_size
"server local" time.
Definition time.h:69
int nonnull(2, 5))