The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
virtual_server.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 60f34b4f4495bec384ba14bf12d1a24c9b18df99 $
19 *
20 * @file tls/virtual_server.c
21 * @brief Calls a section in the TLS policy virtual server.
22 *
23 * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
24 */
25#ifdef WITH_TLS
26#define LOG_PREFIX "tls"
27
28#include <freeradius-devel/unlang/interpret.h>
29#include <freeradius-devel/unlang/call.h>
30#include <freeradius-devel/server/virtual_servers.h>
31
32#include "attrs.h"
33#include "base.h"
34#include "cache.h"
35
36/** Push a request to perform a policy action using a virtual server
37 *
38 * This function will setup a TLS subrequest to run a virtual server section.
39 *
40 * @note FIXME - The result of these callback sections are ignored... We may
41 * want to change this in the future.
42 *
43 * @param[out] child to run as a subrequest of the parent.
44 * @param[in] resume Function to call after the virtual server
45 * finishes processing the request. uctx will
46 * be a pointer to the provided tls_session.
47 * @param[in] conf the tls configuration.
48 * @param[in] tls_session The current tls_session.
49 * @param[in] cache_required Does this action require the tls cache
50 * @return
51 * - 0 on success.
52 * - -1 on failure.
53 */
54unlang_action_t fr_tls_call_push(request_t *child, unlang_function_no_result_t resume,
55 fr_tls_conf_t *conf, fr_tls_session_t *tls_session,
56#ifdef NDEBUG
57 UNUSED
58#endif
59 bool cache_required)
60{
61 fr_assert(tls_session->cache || !cache_required);
62
63 /*
64 * Sets up a dispatch frame in the parent
65 * and a result processing frame in the child.
66 */
67 if (unlang_subrequest_child_push(NULL, child,
68 tls_session,
69 true, UNLANG_SUB_FRAME) < 0) {
70 return UNLANG_ACTION_FAIL;
71 }
72
73 /*
74 * Setup a function to execute after the
75 * subrequest completes.
76 */
77 if (unlang_function_push(child,
78 NULL,
79 resume,
80 NULL,
82 tls_session) < 0) return UNLANG_ACTION_FAIL;
83
84 /*
85 * Now the child and parent stacks are both
86 * setup correctly, push a virtual server
87 * call into the subrequest to run the section
88 * specified by Packet-Type.
89 */
90 if (unlang_call_push(NULL, child, conf->virtual_server, UNLANG_SUB_FRAME) < 0) {
91 request_detach(child);
92 return UNLANG_ACTION_FAIL;
93 }
94
96}
97#endif
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
@ UNLANG_ACTION_PUSHED_CHILD
unlang_t pushed a new child onto the stack, execute it instead of continuing.
Definition action.h:39
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
Definition action.h:36
#define UNUSED
Definition build.h:317
unlang_action_t unlang_call_push(unlang_result_t *p_result, request_t *request, CONF_SECTION *server_cs, bool top_frame)
Push a call frame onto the stack.
Definition call.c:147
unlang_action_t(* unlang_function_no_result_t)(request_t *request, void *uctx)
A generic function pushed by a module or xlat to functions deeper in the C call stack to create resum...
Definition function.h:68
#define unlang_function_push(_request, _func, _repeat, _signal, _sigmask, _top_frame, _uctx)
Push a generic function onto the unlang stack.
Definition function.h:179
#define UNLANG_SUB_FRAME
Definition interpret.h:37
#define fr_assert(_expr)
Definition rad_assert.h:38
static rs_t * conf
Definition radsniff.c:53
int request_detach(request_t *child)
Unlink a subrequest from its parent.
Definition request.c:542
int unlang_subrequest_child_push(unlang_result_t *p_result, request_t *child, void const *unique_session_ptr, bool free_child, bool top_frame)
Push a pre-existing child back onto the stack as a subrequest.
Definition subrequest.c:428