The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
src
modules
rlm_sql
rlm_sql_trunk.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 (at
6
* 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: bcd9c641a4a128de27aa5f2a207089c730ec63c8 $
20
* @file rlm_sql_trunk.h
21
* @brief Macros to reduce boilerplate in trunk SQL drivers
22
*
23
* @copyright 2024 The FreeRADIUS server project
24
*/
25
RCSIDH
(rlm_sql_trunk_h,
"$Id: bcd9c641a4a128de27aa5f2a207089c730ec63c8 $"
)
26
27
/** Allocate an SQL trunk connection
28
*
29
* @param[in] tconn Trunk handle.
30
* @param[in] el Event list which will be used for I/O and timer events.
31
* @param[in] conn_conf Configuration of the connection.
32
* @param[in] log_prefix What to prefix log messages with.
33
* @param[in] uctx User context passed to trunk_alloc.
34
*/
35
#define SQL_TRUNK_CONNECTION_ALLOC \
36
CC_NO_UBSAN(function)
/* UBSAN: false positive - public vs private connection_t trips --fsanitize=function */
\
37
static connection_t *sql_trunk_connection_alloc(trunk_connection_t *tconn, fr_event_list_t *el, \
38
connection_conf_t const *conn_conf, \
39
char const *log_prefix, void *uctx) \
40
{ \
41
connection_t *conn; \
42
rlm_sql_thread_t *thread = talloc_get_type_abort(uctx, rlm_sql_thread_t); \
43
conn = connection_alloc(tconn, el, \
44
&(connection_funcs_t){ \
45
.init = _sql_connection_init, \
46
.close = _sql_connection_close \
47
}, \
48
conn_conf, log_prefix, thread->inst); \
49
if (!conn) { \
50
PERROR("Failed allocating state handler for new SQL connection"); \
51
return NULL; \
52
} \
53
return conn; \
54
}
55
56
#define SQL_QUERY_RESUME \
57
static unlang_action_t sql_query_resume(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx) \
58
{ \
59
fr_sql_query_t *query_ctx = talloc_get_type_abort(uctx, fr_sql_query_t); \
60
if (query_ctx->rcode != RLM_SQL_OK) RETURN_MODULE_FAIL; \
61
RETURN_MODULE_OK; \
62
}
63
64
#define SQL_QUERY_FAIL \
65
static void sql_request_fail(request_t *request, void *preq, UNUSED void *rctx, \
66
UNUSED trunk_request_state_t state, UNUSED void *uctx) \
67
{ \
68
fr_sql_query_t *query_ctx = talloc_get_type_abort(preq, fr_sql_query_t); \
69
query_ctx->treq = NULL; \
70
if (query_ctx->rcode == RLM_SQL_OK) query_ctx->rcode = RLM_SQL_ERROR; \
71
if (request) unlang_interpret_mark_runnable(request); \
72
}
RCSIDH
#define RCSIDH(h, id)
Definition
build.h:484
Generated by
1.9.8