The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
file.h
Go to the documentation of this file.
1/*
2 * file.h
3 *
4 * Version: $Id: 8ebdbd18b5a09b3ca6ecdfdf347dca2f5881bd66 $
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 * @copyright 2025 Network RADIUS SAS (legal@networkradius.com)
21 */
22
23#include "rlm_linelog.h"
24
25/** linelog module thread specific structure
26 */
27typedef struct {
28 fr_hash_table_t *file_table; //!< Hash table of files.
29 fr_timer_list_t *tl; //!< Timer list for this thread.
31
33
34typedef struct {
35 request_t *request; //!< The request that created the data.
36 rlm_linelog_file_t *file; //!< The file being written to.
37 bool failed; //!< Write failed.
38 size_t data_len; //!< How much data this entry holds in the sbuff.
39 int error; //!< Error code if the write failed.
41
42typedef struct linelog_write_uctx_s linelog_write_uctx_t;
43
45 char const *filename; //!< Talloced filename string.
46 fr_value_box_t *log_header; //!< Header to prepend to each log line.
47 rlm_linelog_t const *mod_inst; //!< Module instance this file belongs to.
48 rlm_linelog_thread_t *thread_inst; //!< Thread instance this file belongs to.
49 fr_dbuff_uctx_talloc_t tctx; //!< Talloc context for the dbuff.
50 fr_dbuff_t dbuff; //!< Talloced, dynamically resized dbuff containing
51 //!< all of the linelog content to write out.
52 fr_timer_t *write; //!< When we need to write out any pending data in the buffer.
53 fr_timer_t *expiry; //!< When we should cleanup file metadata due to inactivity.
54 rlm_linelog_file_entry_t *entry_p; //!< Last entry we wrote to.
55 rlm_linelog_file_entry_t *entry_last; //!< Last entry in the array.
56 rlm_linelog_file_entry_t entry[]; //!< Array of metadata for each pending write.
57};
58
59typedef enum {
60 LINELOG_BUFFER_WRITE_FAIL = -1, //!< Writing buffered data failed.
61 LINELOG_BUFFER_WRITE_YIELD = 0, //!< Writing buffered data yielded.
62 LINELOG_BUFFER_WRITE_DONE = 1 //!< Writing buffered data completed.
64
66
68 request_t *request, fr_value_box_list_t *in);
69
70void file_batching_mod_handle_signal(module_ctx_t const *mctx, request_t *request, fr_signal_t action);
71
72void file_batching_xlat_handle_signal(xlat_ctx_t const *xctx, request_t *request, fr_signal_t action);
73
75 linelog_call_env_t const *call_env, request_t *request,
76 struct iovec *vector_p, size_t vector_len);
77
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
static fr_slen_t in
Definition dict.h:884
Temporary structure to hold arguments for module calls.
Definition module_ctx.h:41
struct linelog_write_uctx_s linelog_write_uctx_t
Definition file.h:42
linelog_buffer_action_t file_enqueue_write(rlm_linelog_file_entry_t **entry_p, module_ctx_t const *mctx, linelog_call_env_t const *call_env, request_t *request, struct iovec *vector_p, size_t vector_len)
Definition file.c:270
void file_batching_mod_handle_signal(module_ctx_t const *mctx, request_t *request, fr_signal_t action)
Definition file.c:87
char const * filename
Talloced filename string.
Definition file.h:45
bool failed
Write failed.
Definition file.h:37
fr_dbuff_t dbuff
Talloced, dynamically resized dbuff containing all of the linelog content to write out.
Definition file.h:50
unlang_action_t file_batching_mod_resume(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request)
void file_thread_init(rlm_linelog_thread_t *thread, fr_timer_list_t *tl)
Definition file.c:358
rlm_linelog_file_entry_t entry[]
Array of metadata for each pending write.
Definition file.h:56
rlm_linelog_file_t * file
The file being written to.
Definition file.h:36
fr_dbuff_uctx_talloc_t tctx
Talloc context for the dbuff.
Definition file.h:49
rlm_linelog_t const * mod_inst
Module instance this file belongs to.
Definition file.h:47
fr_timer_list_t * tl
Timer list for this thread.
Definition file.h:29
void file_batching_xlat_handle_signal(xlat_ctx_t const *xctx, request_t *request, fr_signal_t action)
Definition file.c:92
request_t * request
The request that created the data.
Definition file.h:35
fr_value_box_t * log_header
Header to prepend to each log line.
Definition file.h:46
xlat_action_t file_batching_xlat_resume(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
rlm_linelog_file_entry_t * entry_last
Last entry in the array.
Definition file.h:55
fr_hash_table_t * file_table
Hash table of files.
Definition file.h:28
fr_timer_t * write
When we need to write out any pending data in the buffer.
Definition file.h:52
size_t data_len
How much data this entry holds in the sbuff.
Definition file.h:38
int error
Error code if the write failed.
Definition file.h:39
linelog_buffer_action_t
Definition file.h:59
@ LINELOG_BUFFER_WRITE_YIELD
Writing buffered data yielded.
Definition file.h:61
@ LINELOG_BUFFER_WRITE_DONE
Writing buffered data completed.
Definition file.h:62
@ LINELOG_BUFFER_WRITE_FAIL
Writing buffered data failed.
Definition file.h:60
rlm_linelog_file_entry_t * entry_p
Last entry we wrote to.
Definition file.h:54
rlm_linelog_thread_t * thread_inst
Thread instance this file belongs to.
Definition file.h:48
fr_timer_t * expiry
When we should cleanup file metadata due to inactivity.
Definition file.h:53
Definition file.h:34
linelog module thread specific structure
Definition file.h:27
linelog module instance
Definition rlm_linelog.h:47
fr_signal_t
Signals that can be generated/processed by request signal handlers.
Definition signal.h:38
An event timer list.
Definition timer.c:50
A timer event.
Definition timer.c:84
xlat_action_t
Definition xlat.h:37
static size_t char ** out
Definition value.h:1024
An xlat calling ctx.
Definition xlat_ctx.h:49